LED blinker (for PIC18F2550, PIC18F2455)
1. HW
To the USB programmer scheme there were added 2x LEDs and 2x resistors. LEDs are not connected same way - to demonstrate options how you could do it.
Figure 1: PIC18F2550 LED blinker scheme
There are used pins RB6 and RB7 of PIC to control attached LEDs. In a very simple code there is same signal brought into RB6, RB7. But LED will light in opposite - when one is lighting, other one is not.
Figure 2: PIC18F2550 LED blinker on experiment solderless breadboard in action
2. SW
As a starting point I have used application template compatible with another USB HID bootloader. I have modified all necessary places to change start points from 0x1100 to 0x1000 so it will work with Microchip's USB HID bootloader.
Core part of code is port definition section:
- main.c
#define LED1 LATBbits.LATB6 #define LED2 LATBbits.LATB7
and execution part:
- main.c
void main(void) { //init TRIS TRISBbits.TRISB4=0; TRISBbits.TRISB5=0; TRISBbits.TRISB6=0; TRISBbits.TRISB7=0; //infinity loop while(1) { LED1=1; //simple LED Blinking LED2=1; //simple LED Blinking Delay10KTCYx(250); Delay10KTCYx(250); LED1=0; LED2=0; Delay10KTCYx(250); Delay10KTCYx(250); } }
To compile code I have used:
- MPLAB X IDE v1.95 for Windows released on 30.10.2013
- MPLAB C for PIC18 v3.46 in LITE mode released on 3.5.2013
3. Downloads
Archive PIC18F2550 Application template package.zip contains:
- PIC18F2550 / PIC18F2455 LED blinker schematics compatible with USB programmer
- user applications template working/compatible with Microchip's USB HID bootloader including compiled
PIC18F2550_Application_template_RKA.hexfile generated by MPLAB C for PIC18 v3.46 in LITE mode, that you can upload into PIC using USB programmer
If you found these information useful, please consider to:
in USD
(Article created 5.1.2014)