I’ve received a few requests for a simple ‘flashing led’ example for my PIC18F14K50 USB Breakout Board, specifically one compatible with the bootloader. This code here aims to meet that request. Additionally, it serves as a template of sorts for the beginnings of your own HID USB bootloader compatible code.
To keep things simple, all we’re doing here is alternately flashing the two user LEDs on one of my PIC18F14K50 v3 USB Breakout Boards. Aside from this code, you will also need to add a linker script (.lkr file, available in the project download at the end of this article) to your project in order to get it to run on the bootloader. That file is available as part of the project download towards the bottom of this post.
The code requirements to make this compatible with the USB HID Bootloader is actually pretty simple. All that is necessary for this basic example is the code between the “bootloader support code” comments, and the linker file attached to the project as mentioned above. If we were using interrupts, the code would require us to remap those as well, but that’s just a few more lines of code. We’ll save that for a future example. you can also check out Microchip’s USB HID – Mouse demo code for an example which uses interrupts (Available in the Microchip Application Libraries download, http://www.microchip.com/mal)
And now, to the code!:
The code for this example is available via git here: LEDFlash