Please watch the tutorial video first:
VIDEO
You can find the code below:
E:\Users\admin\MPLABXProjects\LED_blink.X\newmainXC16.c
1 /*
2
3
4
5
6
7
8
9
10
11
12
13 # pragma config BWRP = OFF
14 # pragma config BSS = DISABLED
15 # pragma config BSEN = OFF
16 # pragma config GWRP = OFF
17 # pragma config GSS = DISABLED
18 # pragma config CWRP = OFF
19 # pragma config CSS = DISABLED
20 # pragma config AIVTDIS = OFF
21
22
23 # pragma config BSLIM = 0x1FFF
24
25
26 # pragma config FNOSC = OSCFDIV
27 # pragma config PLLMODE = DISABLED
28 # pragma config IESO = ON
29
30
31 # pragma config POSCMD = NONE
32 # pragma config OSCIOFCN = OFF
33 # pragma config SOSCSEL = ON
34 # pragma config PLLSS = PLL_PRI
35 # pragma config IOL1WAY = ON
36 # pragma config FCKSM = CSDCMD
37
38
39 # pragma config WDTPS = PS32768
40 # pragma config FWPSA = PR128
41 # pragma config FWDTEN = ON
42 # pragma config WINDIS = OFF
43 # pragma config WDTWIN = WIN25
44 # pragma config WDTCMX = WDTCLK
45 # pragma config WDTCLK = LPRC
46
47
48 # pragma config BOREN = ON
49 # pragma config LPCFG = OFF
50 # pragma config DNVPEN = ENABLE
51
52
53 # pragma config ICS = PGD1
54 # pragma config JTAGEN = OFF
55
56
57 # pragma config DMTIVTL = 0xFFFF
58
59
60 # pragma config DMTIVTH = 0xFFFF
61
62
63 # pragma config DMTCNTL = 0xFFFF
64
65
66 # pragma config DMTCNTH = 0xFFFF
67
68
69 # pragma config DMTDIS = OFF
70
71
72 # pragma config ALTCMPI = DISABLE
73 # pragma config TMPRPIN = OFF
74 # pragma config SOSCHP = ON
75 # pragma config ALTI2C1 = ALTI2C1_OFF
76 # pragma config SMB3EN = SMBUS3
77
78
79
80
81
82 # include "xc.h"
83 # define _XTAL_FREQ 20000000
84 int i =0;
85 void main (void ) {
86 TRISG = 0b00000000;
87 TRISB = 0b00000000;
88 while (1){
89 PORTGbits.RG7 = 1;
90 for (i=1;i<20000;i++);
91 PORTGbits.RG7 =0;
92 for (i=1;i<20000;i++);
93
94 return ;
95
96 }
97 }
98