-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathISRs.h
77 lines (72 loc) · 1.65 KB
/
ISRs.h
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
#include "Temperature.h"
// ****** GLOBAL VARIABLES ****** //
int value = 0;
int count = 0;
int Flag = 0;
// ***** PROTOTYPES ****** //
void __interrupt() ISR();
// ***** FUNCTIONS **** //
void __interrupt() ISR(){
//Sensor ISR
if(TMR1IF==1){
TempSensor();
TMR1H=0x0B; // Load the time value(0xBDC) for 100ms delay
TMR1L=0xDC;
TMR1IF=0; // Clear timer interrupt flag
GIE = 1; //Enable global interrupt
}
//LED ISR
if(TMR2IF==1){
TMR2 = 101;
if(count>=200){ //5ms *200 = 1000 ms = 1sec
count=0;
value=~value;
Led = value;
}
else{
count++; // Keep incrementing the count till it reaches 200 to generate 1sec delay
}
TMR2IF=0; // Clear timer interrupt flag
GIE = 1;
}
//ON/OFF Button ISR
if(INTF==1){
Flag = ~Flag;
if(Flag){
TMR1ON=OFF;
TMR2ON =OFF;
PORTA=OFF;
PORTB=OFF;
PORTC=OFF;
PORTD=OFF;
INTF=0;
GIE = 1;
SLEEP();
}
else if(!Flag){
TMR1ON=ON;
TMR2ON =ON;
PORTA=ON;
PORTB=ON;
PORTC=ON;
PORTD=ON;
}
INTF=0;
GIE = 1;
}
/*if(RBIF==1){
RBIE=0;
TMR1ON=OFF;
TMR2ON =OFF;
SettingMode();
TMR1ON=ON;
TMR2ON =ON;
RBIE=1;
RBIF=0;
GIE = 1;
}
if(Up == 0 || Down == 0){
__delay_ms(10);
SettingMode();
}*/
}