-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWDT.c
48 lines (34 loc) · 947 Bytes
/
WDT.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
#include "WDT.h"
#include <p18cxxx.h>
#include "oled.h"
#include "PushButton.h"
#include "isr.h"
static int x = 1; // PushButton_flag
//#pragma config WDTEN = OFF // software control the watchdog
#pragma config WDTPS = 512 // 1:512 postscalar, gives 2sec delay
void WDT_init() //initialize the watchdog
{
WDTCONbits.SWDTEN = 1; // enable watchdog
}
void Main_RunWDT ()
{
char BP[5];
int counter = 0;
PushButton_Init(); // initialize pushbutton for interrupts
Oled_Init();
Oled_Clear();
WDT_init();
while (1)
{
while (pbPressedFlag) // while Pushbutton_Flag is true
{
counter ++;
sprintf(BP,"%d",counter); // convert the variables into a string
Oled_PutString(BP,10, 12, 0); // print the time to the screen
ClrWdt(); // clear the watchdog
}
while (pbPressedFlag) // when pushbutton_flag = false
{
}
}
}