You are on page 1of 2

Department of Electronic and Telecommunication Engineering, University of Moratuwa

EN2060: Robot Design and Competition Laboratory Guide


Title: Bootloader 1. What is a Bootloader
The PIC16F87X family of microcontrollers has the ability to write to their own program memory. This feature allows a small bootloader program to receive and write new firmware into memory. In its most simple form, the bootloader starts the user code running, unless it finds that new firmware should be downloaded. If there is new firmware to be downloaded, it gets the data and writes it into program memory. There are many variations and additional features that can be added to improve reliability and simplify the use of the bootloader.

2. How to create mikroBootloader HEX file


1. Open Bootloader Project file in MikroElectronica Examples folder according to the Microcontroller type and FLASH size. For 16F microcontrollers \Mikroelektronika\mikroC PRO for PIC\Examples\Other\Bootloader\P16 For 18F microcontrollers \Mikroelektronika\mikroC PRO for PIC\Examples\Other\Bootloader\P18 2. Change the project settings to your preferred microcontroller and the Oscillator frequency. Ex : Device : PIC16F877A MCU Clock : 4.000000 MHz 3. Open the datasheet of the microcontroller and scroll down for BAUD RATES FOR ASYNCHRONOUS MODE (BRGH = 1) under the topic of Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART). 4. Select the SPBRG value according to Oscillator frequency and Baud Rate. Ex : For 9600 Baud Rate 16 MHz 103 8 MHz 51 4MHz 25 5. Update the project with SPBRG value and compile the project to generate the HEX file.

3. How to use mikroBootloader


Note : mikroBootloader can be used only with PIC MCUs that support flash write.

1. Load the MCU with the appropriate HEX file using the conventional programming techniques. 2. Start mikroBootloader from the drop-down menu Tools Bootoader. 3. Click on Change Settings and select the COM port and the BAUD that will be used.

1|Page

Department of Electronic and Telecommunication Engineering, University of Moratuwa

4. Click on Connect and wait until connected. Since the bootcode in the MCU only gives the computer 4-5 sec to connect, you should reset the MCU and then click on the Connect button within 4-5 seconds. 5. Click on Browse for HEX and select the HEX file you would like to upload. 6. The last line in then history window should now read Connected. 7. To start the upload, just click on the Begin uploading button. 8. Your program will written to the MCU. Bootloader will report an errors that may occur. 9. Reset your MCU and start to execute. Important : In your MikroC program main function should defined with org keyword as below. Otherwise bootloader will erase the Bootloader HEX Firmware. void main() org 0x0200{ }

2|Page

You might also like