Introduction
In previous post of Timer0 interrupt programming, we use its interrupt advantage to create a timer tick in a range of milli second. We can decorate some more features over this capability.
A precise timing delay function can be created using timer0 interrupt programming. In this example we create a delay function from the existing 1ms-delay routine that it was written in previous example.
Program simulation sample |
Programming
Delay function created by adding more routine that rely on free running counter in the ISR coding of Timer0 interrupt.
void ms_delay(unsigned count) {
while(ms_count<count);
ms_count=0;
}
There is no change in source code but it excepts only one additional routine that handle timing delay.
Schematic Diagram |
Program in MikroC
Click here to download source file.
No comments:
Post a Comment