-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathISR.c
More file actions
57 lines (51 loc) · 1.08 KB
/
ISR.c
File metadata and controls
57 lines (51 loc) · 1.08 KB
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
#include "tm4c123gh6pm.h"
#include "dio.h"
#include "port.h"
#include "typedefs.h"
#include "project.h"
#include "tm4c123gh6pmm.h"
//global variables
static volatile uint16 counter=0;
void GPIOA_Handler ()
{
//INCREMENT
if(GPIO_PORTA_RIS_R & (0x01 << 5 ))
{
//considering bouncing effect
Systick_wait10ms (20);
if(!(GPIO_PORTA_DATA_R & (0x01 << 5 )))
{
do{
counter ++;
if (counter== 1000) counter=0;
display (counter);
Systick_wait10ms(200);
}
while(!(GPIO_PORTA_DATA_R & (0x01 << 5 )));
}
}
//DECREMENT
else if( GPIO_PORTA_RIS_R & (0x01 << 6 ))
{
//considering bouncing effect
Systick_wait10ms (20);
if(!(GPIO_PORTA_DATA_R & (0x01 << 6 )))
{
if(counter == 0) counter = 999;
else counter--;
display (counter);
}
}
//RESET
else if(GPIO_PORTA_RIS_R & (0x01 << 7 ))
{
//considering bouncing effect
Systick_wait10ms (20);
if(GPIO_PORTA_DATA_R & (0x01 << 7 ))
{
counter = 0;
display (counter);
}
}
GPIO_PORTA_ICR_R |= 0xFF; //CLEARING FLAG OF INTERRUPT
}