-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
69 lines (56 loc) · 964 Bytes
/
main.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
#include "dsPIC33f_i2c.h"
__CONFIG(FWDT, WDTDIS);
//to check GIT
void tglePort(void)
{
static char ch=0;
if(ch == 0)
{
ch =1;
PORTBbits.RB4 = 0x0;
}
else
{
ch = 0;
PORTBbits.RB4 = 0x1;
}
}
int delay(long int period)
{
long int i=0,j=0;
for(i=0;i<3;i++)
for(j=0;j<period;j++);
return 0;
}
int initPorts(void)
{
LATA = 0x0000; // set latch levels
TRISA = 0x0000; // set IO as outputs
LATB = 0x0000; // set latch levels
TRISB = 0x0000; // set IO as outputs
OSCCON=0x0680;
TRISAbits.TRISA3 = 1; //User Input switch- Defineing as input
PORTBbits.RB4 = 0x1; //Set High, which make LED to Turn OFF
PORTAbits.RA4 = 0x1; //User LEd, turn off
while(1)
{
tglePort();
delay(5000);
}
return 0;
}
int init()
{
initPorts();
initUART1();
initI2C();
return 0;
}
int main()
{
init();
while(1){
delay(50);
}
return 0;
}