1 | #include <stdio.h>
|
2 | #include <stdlib.h>
|
3 | #include <pic18f2550.h>
|
4 | #include <delays.h>
|
5 |
|
6 |
|
7 |
|
8 | // PIC18F2550 Configuration Bit Settings
|
9 |
|
10 | #include <xc.h>
|
11 |
|
12 | #define _XTAL_FREQ 8000000
|
13 |
|
14 | // CONFIG1L
|
15 | #pragma config PLLDIV = 1
|
16 | #pragma config CPUDIV = OSC1_PLL2// PLL Prescaler Selection bits (No prescale (4 MHz oscillator input drives PLL directly))
|
17 | #pragma config USBDIV = 1 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes directly from the primary oscillator block with no postscale)
|
18 |
|
19 | // CONFIG1H
|
20 | #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator (HS))
|
21 | #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
|
22 | #pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
|
23 |
|
24 | // CONFIG2L
|
25 | #pragma config PWRT = ON // Power-up Timer Enable bit (PWRT enabled)
|
26 | #pragma config BOR = OFF // Brown-out Reset Enable bits (Brown-out Reset disabled in hardware and software)
|
27 | #pragma config BORV = 3 // Brown-out Reset Voltage bits (Minimum setting)
|
28 | #pragma config VREGEN = OFF // USB Voltage Regulator Enable bit (USB voltage regulator disabled)
|
29 |
|
30 | // CONFIG2H
|
31 | #pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit))
|
32 | #pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
|
33 |
|
34 | // CONFIG3H
|
35 | #pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
|
36 | #pragma config PBADEN = OFF // PORTB A/D Enable bit (PORTB<4:0> pins are configured as digital I/O on Reset)
|
37 | #pragma config LPT1OSC = OFF // Low-Power Timer 1 Oscillator Enable bit (Timer1 configured for higher power operation)
|
38 | #pragma config MCLRE = ON// MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
|
39 |
|
40 | // CONFIG4L
|
41 | #pragma config STVREN = OFF // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
|
42 | #pragma config LVP = OFF // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
|
43 | #pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
|
44 |
|
45 | // CONFIG5L
|
46 | #pragma config CP0 = OFF // Code Protection bit (Block 0 (000800-001FFFh) is not code-protected)
|
47 | #pragma config CP1 = OFF // Code Protection bit (Block 1 (002000-003FFFh) is not code-protected)
|
48 | #pragma config CP2 = OFF // Code Protection bit (Block 2 (004000-005FFFh) is not code-protected)
|
49 | #pragma config CP3 = OFF // Code Protection bit (Block 3 (006000-007FFFh) is not code-protected)
|
50 |
|
51 | // CONFIG5H
|
52 | #pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) is not code-protected)
|
53 | #pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
|
54 |
|
55 | // CONFIG6L
|
56 | #pragma config WRT0 = OFF // Write Protection bit (Block 0 (000800-001FFFh) is not write-protected)
|
57 | #pragma config WRT1 = OFF // Write Protection bit (Block 1 (002000-003FFFh) is not write-protected)
|
58 | #pragma config WRT2 = OFF // Write Protection bit (Block 2 (004000-005FFFh) is not write-protected)
|
59 | #pragma config WRT3 = OFF // Write Protection bit (Block 3 (006000-007FFFh) is not write-protected)
|
60 |
|
61 | // CONFIG6H
|
62 | #pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
|
63 | #pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0007FFh) is not write-protected)
|
64 | #pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
|
65 |
|
66 | // CONFIG7L
|
67 | #pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000800-001FFFh) is not protected from table reads executed in other blocks)
|
68 | #pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (002000-003FFFh) is not protected from table reads executed in other blocks)
|
69 | #pragma config EBTR2 = OFF // Table Read Protection bit (Block 2 (004000-005FFFh) is not protected from table reads executed in other blocks)
|
70 | #pragma config EBTR3 = OFF // Table Read Protection bit (Block 3 (006000-007FFFh) is not protected from table reads executed in other blocks)
|
71 |
|
72 | // CONFIG7H
|
73 | #pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0007FFh) is not protected from table reads executed in other blocks)
|
74 |
|
75 |
|
76 | int main(void) {
|
77 |
|
78 | PORTC = 0x00;
|
79 | LATC = 0x00;
|
80 | TRISC = 0x00;
|
81 |
|
82 |
|
83 | while(1){
|
84 |
|
85 | PORTC = 0xFF;
|
86 | __delay_ms(50);
|
87 | PORTC = 0x00;
|
88 | __delay_ms(50);
|
89 | }
|
90 |
|
91 | }
|