Friday, April 3, 2015

USB HID Bootloader Circuit - 18F4550

Update:

28/11/2015
If you are use mikroC PRO, then tick the Long Hex format in output settings and rename the generated hex file to scp.hex. Finally run mod.exe. It will generate new hex file (mod.hex) and use it with PICDEM software. Otherwise, program may not work correctly.


Boot-loader is a program which helps to program the micro-controller device without using external programmer. It is possible to burn the hex code even if the PC doesn't have a serial port or any other tools.

Required tools for Boot-loader are:
  • USB cable to connect board to the PC
  • A micro controller with already flashed boot loader program

USB HID Bootloader circuit
Boot-loader circuit

The boot-loader starts after Power-On or Reset. The boot-loader checks if pin RE3 is low or high:
  • RE3 = low (0V) : PIC starts in boot-loader mode
  • RE0 = high (5V) : PIC starts user application

Install Boot-loader program

For installing boot-loader program, we need an external programmer. This is a one time process which doesn't need to repeat. Use any programmer like JDM, PicKit, ICD3 to flash the provided boot-loader program USB HID Bootloader.hex.

After successfully programming, connect your device to the PC's USB port (if not already connected). Please make sure that the boot-loader entry condition (RE3 = 0) is fulfilled!

Windows should detect a new USB device. Now open boot-loader PC software and click connect, browse hex file, begin upload.

After finishing upload, click execute. Device will reset automatically and start your program.

Example

void main(); void interrupt() { //-------- interrupt ----------- } void interrupt_low() { } void Vectors() org 0x800 { //-------- remap --------- asm { goto _main //0x800 nop nop goto _interrupt //0x808 nop nop nop nop nop nop goto _interrupt_low //0x818 } } void main() { //----- Main -------- OrgAll(0x800); asm {goto Skip_Vectors} Vectors(); asm {Skip_Vectors:} /* Your Code goes here */ }

1 comment: