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 :
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 :
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.