Probably me in a soon future........ Boot Loader for PIC16F870
A boot loader software will make the programming of PIC16F870 very easy for you.
No complex programmers are needed, and no need to remove the circuit from the circuit board.
Any computer with a standard serial communication interface will be able to handle the programming.
Just connect the computer and download the HEX file as it is.
All contribution to this page are most welcome!

Background
A bootloader is a program that stays in the micro controller and communicates with the PC (usually through the serial interface).
The bootloader receives a user program from the PC and writes it in the flash memory, then launches this program in execution.
Bootloaders can only be used with those micro controllers that can write their flash memory through software as PIC16F870.
Let's take a look inside the memory of the PIC16F870 and you will soon understand how it all works.

Memory of PIC16F870

After a reset or power up, the PIC16F870 jump to its reset address which is 0000 hex (blue memory address).
This address can not be changed in any way.
This means that the normal software should start at the address 0000 hex. From address 0001 to 072f hex the flash memory is empty.
At address 0730 hex, I have placed the boot loader software.

So what is this good for?
After a reset the PIC16F870 jumps to the boot software (pink memory address). The first thing the boot software does is to check if there is any computer connected, and if there is communication waiting to be transferred. If a computer is connected and want to communicate, the boot software will set up communication and handle all programming to load new hex code into the PIC16F870 flash memory. If no computer is connected, the boot software will end its task, and jump to address 0010 hex (green memory address) where the user software will be present and starts to execute.

Advantage/disadvantage with boot loader
+ You can reprogram the PIC16F870 very quick and easy.
+ You need no special programming device to program the PIC16F870.
+ No neeed of external high power, only standard +5V.
+ Easy way to download new software.

- The PIC16F870 must be loaded with a boot software one time to work. (I can fix that for you, click to read more)
- You must be careful not to overwrite boot software in memory address 0730-07ff hex. Although warnings for overwrite i implemented in the software.
- To keep correct bauderate, you must use a 4.9152MHz crystal while the boot software is loading new software.
(Other crystal can be used to run the PIC, but to re-program the PIC with the bootloader you MUST use the 4.9152 MHz crystal)

The boot loader software Practical example

To make this even more clear I will show a practical example.

Click "Open file" and select your hex file.
If you already have chosen the file and you just want to reload it, you can click "Reload".

Choose comport and click "Start Programming".

The software now waits for the boot loader software to wake up, so connect the power (+5V) to the PIC16F870. Transfer of the hexfile will now start between the computer and the PIC16F870.

When the computer has finished sending all the bytes to the PIC16F870, the bootloader will wait for 3 seconds and then start to execute the downloaded software.




Important to know

Since the start address 0000 hex is set for the boot loader software your NEW start is always 0010 hex
This means that when you write your code you must always think that the start is at address 0010 hex.
Look at the code below, it is the start lines of a program and as you can see it starts at address 0010 hex.

STARTADR: ORG 010h             ;Point to address 010h which is the start address
          GOTO START           ;Jump to START of user program

Hardware
Below you will see a schematic of a basic setup to get a PIC16F70 running.

To the left you see the PIC16F870 with a crystal of 4.9152MHz.
To the right you see a simple RS232 to TTL converter. This converter is nessesary becasue the RS232 line is +/- 12V and not 0/+5V as in TTL.
I advice you to build the converter separately so you can use it for all your projects involving RS232 communication.

Download programs
boot.rar Boot loader software (file is zipped!).

Windows software
Click here to visit the download site for the Windows software.

Need Parts
I can of course supply you with PIC16F870 pre-programmed with Boot loader software for no extra costs. PICs can be found att my rfcandy shop page.
(In the form you can write info that you wish it to be pre-programmed with boot loader.)

Final word
I developed this boot loader program becasue I needed a simple and fast programming tool to my PIC16F870.
With the boot loader software I do not need to remove the PIC from the construction and I can develop and test PIC software much faster.
Now I only need to compile my ASM code and press the Reload button to download and test the new code.



Back to main Page  |  Contact Me  |  Cheap components

Copyright © Last modified on 22 June 2008.