To transfer the HEX file on to PIC Flash memory you need a programmer like PICKIT2 or PICKIT3.As a student you may not wish to shell out the bucks to buy one.The solution is PIC BOOTLOADER & this post is a tutorial on how to implement Boot loader on a PIC16F877A chip.
Remember that the Boot loader itself must be fused on to the Flash memory using an external programmer like PICKIT2.Once the chip is boot loaded the external programmer is not needed for further programming.
Whenever a boot loaded chip is re started ,the program counter jumps to the boot loader section & waits for the instruction which is fed through the serial communication port.A Bootloader is the first program which executes (before the main program) whenever a system is initialized. In case there is no communication in the serial port, the program counter will jump to the preloaded program at 0000H & executes the program.
Mostly the bootloader resides in the bottom most area of the ROM but there are some cases where the boot loader can be configured in the top (like in PIC18F).The starting and ending address of the bootloader in the ROM depends on the product.
TINY BOOTLOADER is one such loader for PIC 16F & 18F ICs.
As all other bootloaders, this consists of a Windows application running on the PC and boot loader firmware running on the target PIC chip.
Download the boot loader zip file from :
http://www.etc.ugal.ro/cchiculita/software/tinybld198.zip
Features of the firmware
- Size of only 100 words; (all versions, for 16F,18F,dsPIC occupy less than 100 words);
- Can write flash, eeprom and configuration bytes(18F);
- On reset, waits 1 second (adjustable) for a message from the PC, if not received, launch user application;
- The .asm file can be easily modified and adapted for any frequency (or baudrate);
- Unzip the downloaded TINY PIC BootLoader.Under the folder named “picsource” is given the Boot loader Hex files for PIC16F & PIC18F ICs.Select 16f & then select the hex file “tinybld_16F876A_20MHz.HEX “ .
- This is the boot loader firmware compatible to PIC16F877A .The selection of crystal frequency 20MHz is important & ensure that the target board uses the same value crystal 20MHz.
- The “tinybldWin” found in the top folder is the Windows application through which you can load the HEX file on to the arget chip PIC16F877A.
New Windows application can be downloaded from :
http://www.etc.ugal.ro/cchiculita/software/TinyBld_1_10_6_pc_beta.zip
To fuse the Boot loader firmware on to the target chip you need PICKIT2 hardware.
Place the PIC16F877A chip on to the ZIF socket of PICKIT2 programmer (pin 1 always near the handle).Start the application PICKIT2.
The hardware is detected automatically and device name is displayed PIC16F877A.
Click on File –> Import HEX
Browse to the location where you’ve unzipped the downloaded folder & select the firmware Hex file
“tinybld_16F876A_20MHz.HEX “ .
The document of TINY BOOTLOADER says this is the matching firmware for PIC16F877A
Click on WRITE to fuse the firmware n to the target chip.
Now your PIC IC is BOOT LOADED & ready to accept your Program Hex files through the Serial port.
To load your program HEX files you need an USB to UART converter.Here I’ve used one built on Silicon Labs CP2102.
The converter is connected to PC using USB cable.A RS232 STRAIGHT cable is used to connect the Target board with UART converter.
Check out the connections between PIC & MAX232 ICs on your target board.
RC6 (PIN 25) should go to pin 11 of MAX232
RC7 (PIN 26) goes to PIN 12 of MAX 232.
PIN 13 of MAX 232 goes to pin 3 of the DB9 connector.
PIN 14 of MAX232 goes to pin 2 of DB9 connector.
Double check these connections, otherwise your Target chip won’t be detected by the Windows application.
Now start the Windows application & click on CHECK PIC button.Your target chip is detected & displayed.The default Baud rate is 115200 .
You can also check the Search button to scan for the port where the Target board is connected.
Click on BROWSE & navigate to the HEX file you’ve created using MPLAB.
Click on WRITE FLASH to fuse the HEX file on to the Target.
Now the Boot loaded chip is fused with your program.On Power On restart the chip will start the Boot loader.After 1 sec wait , it will launch your program.
hello..i wanna a question..when u load for the second .hex file, is it rewrite the first bootloader.hex or not?
While power is ON, the bootloader looks for the hex file at the serial port.If nothing arrives at serial port within stipulated time,the microcontroller will execute the previous hex file loaded.You can overwrite the previous hex file , but not the bootloader file itself.
sir, can i use any other microcontroller like pic16F84, ATMEL controllers instead of this pic16f877a. could u please help me these doubt which will help me to bring this .
No. The bootloader is specific to PIC16F877A only.
The title of this article should really be “PIC BOOT LOADER–Pickit2 Programmer Required Initially and then no Programmer required to fuse Hex file later” … since u in fact are using the PicKit 2 Programmer, I don’t see why you’d say “No Programmer Required”…however, this article definitely helped get me started! Thanks!
sir i don’t have 20mh cristal oscillator but i have 27mh can i use it? dose it have a problem?
As per datasheet of Microchip , the max. operating freq is 20MHz.But you may try with 27 , which will cause some delay/timing errors.
I have pic18f26k22. can I get bootloader for the above said chip?