c util file

This commit is contained in:
Ziver Koc 2008-11-21 14:37:35 +00:00
parent 7748d4a1f5
commit 19025584c9

14
c/util_z.c Normal file
View file

@ -0,0 +1,14 @@
// Delays a multiple of 1 milliseconds at 4 MHz
// using the TMR0 timer
void delay_ms( uns16 millisec){
char next = 0;
OPTION = 2; // prescaler divide TMR0 rate by 8
TMR0 = 2; // deduct 2*8 fixed instruction cycles delay
do {
next += 125;
clrwdt(); // needed only if watchdog is enabled
while (TMR0 != next) // 125 * 8 = 1000 (= 1 ms)
;
} while ( -- millisec != 0);
}