Code C - [expand ] 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
/*
* File: main.c
* Author: EmbeddedKhan
*
* Created on March 14, 2017, 8:19 PM
*/
// DSPIC33FJ128MC804 Configuration Bit Settings
#include <p33FJ128MC804.h>
// 'C' source line config statements
#pragma config BWRP = WRPROTECT_OFF
#pragma config GWRP = OFF //User program memory is not write-protected
#pragma config FNOSC = PRI // Oscillator Mode (Primary Oscillator (XT, HS, EC) w/ PLL)
#pragma config POSCMD = HS // Primary Oscillator Source (HS Oscillator Mode)
#pragma config OSCIOFNC = ON // OSC2 Pin Function (OSC2 pin has clock out function)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor (Both Clock Switching and Fail-Safe Clock Monitor are disabled)
#pragma config IESO = OFF
#pragma config ICS = PGD3 // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
#pragma config JTAGEN = OFF
#pragma config FPWRT = PWR1
#pragma config FWDTEN = OFF//ON
#pragma config WDTPOST = PS1024
#pragma config WDTPRE = PR128
#pragma config LPOL = OFF
#pragma config IOL1WAY = ON
//#pragma config HPOL = ON
#pragma config PWMPIN = OFF
#define TestLED LATBbits.LATB13
void Delay( unsigned int Time) ;
void Delay( unsigned int Time) {
unsigned int i, j;
for ( i = 0 ; i < 120 ; i++ )
for ( j = 0 ; j < Time; j++ ) ;
return ;
}
void GPIOConfig( void ) {
TRISB = 0 ;
Nop( ) ;
TestLED = 0 ;
return ;
}
int main( void ) {
TestLED = 0 ;
GPIOConfig( ) ;
// LATBbits.LATB13 = 1;
// LATAbits.LATA7 = 1;
while ( 1 ) {
Delay( 100 ) ;
TestLED = 1 ;
Delay( 1000 ) ;
TestLED = 0 ;
Delay( 1000 ) ;
}
return 0 ;
}
Last edited by a moderator: Mar 21, 2017