µ[micro]electronics info

A weblog focused on interesting circuits, ideas, schematics and other information about microelectronics and microcontrollers.




Because I have not tested all electronic circuits mentioned on this pages, I cannot attest to their accuracy; therefore, I do not provide a warranty of any kind and cannot be held responsible in any manner.

My e-mail

My website

Unicorn USB bootloader

My first experiment: How to modify standard Microchip's USB bootloader for the Unicorn experimenter kit.

As I wrote a few days ago, I'm happy owner of the Unicorn experimenter kit now. My first experiment with this kit (omitting the "Hello world" on LCD) was an attempt to run standard Microchip's USB bootloader.

I'm not sure if I may distribute whole source code. So I describe only the changes I've made in the codes step by step:

1. Download and install Microchip's USB bootloader

2. You can find the USB bootloader in c:\MCHPFSUSB\fw\boot (the path can be different)

3. The most "system dependent" information are in io_cfg.h file. I've slightly modify the LED information this way:
#define mInitAllLEDs() LATC &= 0xfd; TRISC &= 0xFD;
#define mLED_1 LATCbits.LATC1
#define mLED_2 LATCbits.LATC1
#define mLED_3 LATCbits.LATC1
#define mLED_4 LATCbits.LATC1

and the "switches" part:

#define mInitAllSwitches() TRISBbits.TRISB0=1;TRISBbits.TRISB1=1;
#define mInitSwitch2() TRISBbits.TRISB0=1;
#define mInitSwitch3() TRISBbits.TRISB1=1;
#define sw2 PORTBbits.RB0
#define sw3 PORTBbits.RB1

4. I've slightly modified the main.c file too. I've changed the main() function this way:
void main(void)
//Check Bootload Mode Entry Condition
if (sw2 + sw3) {
_asm goto RM_RESET_VECTOR _endasm
} else {
//Bootload Mode

other code remained unchanged.

5. The MCHPUSB.mcw has its own configuration data; they're, fortunatelly, compatible with the Unicorn. So after these changes you can directly compile the code and programm FLASH.

With this bootloader you can switch the Unicorn to the "boot mode" simply: Hold the both switches SW1 and SW2 and plug Unicorn into the USB. The LED will flash (if you hacked the Unicorn PCB error as I described) and your PC will find "The PIC18F4550 device". System will ask you for the drivers; you should provide the ones located in "MCHPFSUSB\Pc\MCHPUSB Driver\Release".

Once you have Unicorn with bootloader, you can upload your SW using the PDFSUSB.exe utility (MCHPFSUSB\PC\Pdfsusb).

Good luck!

Powered by Drupal - Design by Artinet