-
Notifications
You must be signed in to change notification settings - Fork 0
/
delay.c
88 lines (71 loc) · 1.26 KB
/
delay.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
high level delay routines - see delay.h for more info.
Designed by Shane Tolmie of www.microchipC.com corporation. Freely distributable.
Questions and comments to webmaster@microchipC.com.
PICuWEB - Program PIC micros with C. Site has FAQ and sample source code.
www.microchipC.com.
For Microchip 12C67x, 16C7x, 16F87x and Hi-Tech C
*/
#ifndef __DELAY_C
#define __DELAY_C
#include <htc.h>
#include "always.h"
unsigned char delayus_variable;
#include "delay.h"
void fDelay_big_us(unsigned int cnt)
{
unsigned char i;
i = (unsigned char)(cnt>>8);
while(i>=1)
{
i--;
fDelay_us(253);
CLRWDT();
}
fDelay_us((unsigned char)(cnt & 0xFF));
}
void fDelay_ms(unsigned char cnt)
{
unsigned char i;
do {
i = 4;
do {
fDelay_us(250);
CLRWDT();
} while(--i);
} while(--cnt);
}
//this copy is for the interrupt function
void fDelay_ms_interrupt(unsigned char cnt)
{
unsigned char i;
do {
i = 4;
do {
fDelay_us(250);
} while(--i);
} while(--cnt);
}
void fDelay_big_ms(unsigned int cnt)
{
unsigned char i;
do {
i = 4;
do {
fDelay_us(250);
CLRWDT();
} while(--i);
} while(--cnt);
}
void fDelay_sec(unsigned char cnt)
{
unsigned char i;
do {
i = 4;
do {
fDelay_ms(250);
CLRWDT();
} while(--i);
} while(--cnt);
}
#endif