c util file
This commit is contained in:
parent
7748d4a1f5
commit
19025584c9
1 changed files with 14 additions and 0 deletions
14
c/util_z.c
Normal file
14
c/util_z.c
Normal 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);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue