Search this site (www.microchipC.com).



This site is non-profit. Ad revenue almost covers hosting costs.



CCS C Compiler for Microchip PIC micros

Your ad here

 

PIC18Fx52 bootloader v1.5

Introduction - Background - Step-by-Step - Download - Source Code - Picture Gallery - Debugging - Troubleshooting - FAQ - Feedback

Introduction

This bootloader is compatible with the PIC18F252 and the PIC18F452, running at either 3.68Mhz, 10Mhz, 20Mhz or 40Mhz.

Background

  • Severely battle tested over the last 4 months, with no problems.
  • Tested from -40 to +35 degrees celsius.

Step by Step

  1. Download windows software.
  2. Select your frequency - 3.68Mhz, or 20Mhz.
  3. Program this .hex kernel into the micro using a programmer such as the ICD2 from www.microchip.com (search for ICD2 fro the main page), P16PRO from www.picallw.com. A list of 3rd party programmers is available.
  4. Connect your PIC18Fx52 microcontroller to a spare serial port on your PC such as COM1 or COM2. Follow the supplied circuit diagram.
  5. Select the .hex file by clicking on 'Select Hex File', match the options to the screenshot above, and reset your micro.
  6. The new program will be bootloaded into the micro.
  7. A sample .hex file is supplied that flashes a LED on RC0 at a visible 3Hz. Bootload this file into your micro for testing purposes. Download flashing RC0 tester file. (1k)..

Debugging

If the tick boxes 'SFR' and 'RAM and 'ERPROM' are ticked, adding the line ...

asm("call 0x7000"); //trigger the graphical output SFR, RAM and EEPROM

... to your program dumps the contents of the EEPROM and the Special Function Registers (SFR) into a window. The program halts at this point, and the micro has to be reset, but it is extremely useful for debugging.

A sample .hex file with this "call 0x7000" instruction is available to demonstrates this debugging capability. Download test hex file (3k).



Troubleshooting

Testing the Serial Port

If you have trouble getting the bootloader to work, test to see if the PC is communicating properly with the PIC18Fx52 micro, via the serial port.

  1. Download the appropriate .hex file for your 18Fx52 from the list below.

    Serial port tester .hex file for 18Fx52 micro and:
  2. Program this .hex file into your PIC18Fx52 micro.
  3. Download a Windows terminal program, to look at the serial port. Terminal 1.9b is supplied. Download (463k).
  4. If the PIC is communicating properly with the PC, the Windows terminal program will display '[alive]' at 19.2kbaud, on COMx, every 2 seconds. Pressing a key displays the string [key pressed: X] where X is the key. This verifies that both TX and RX are working on the serial port.
  5. If the PIC18Fx52 is communicating properly with the PC via the serial port, the bootloader should also work with no problems.

Download

Download latest version from GitHub.
(old) Binaries: Windows™ software and PIC18Fx52 .hex files.
(old) Source: Windows™ software and PIC18Fx52 bootloader C code. Compiles with Hi-Tech C.
(old) Prebuilt hex files: custom frequencies.

There is also a version for Linux (and possibly Mac) using Python.

Picture Gallery

The pictures below show the header that was made up for the 18F252 bootloader. As you can see in the picture, there is an 18F452 chip in the header.

The reset button is visible closest to the camera lens. The gold colored microphone jack on the rear of the board carries the RS232 signal (at TTL levels) to the board. The 2 way switch at the rear of the board allows selection of either the serial port in the target circuit, or the on-board serial port.

The RS232 signals (+13 volts and -13 volts) are converted to TTL signals (0 volts and +5 volts) inside the DB9 connector. This DB9 connector goes straight into the gold colored microphone jack plug shown in the two pictures above. The reverse of the connector board shown below is bare of components.

FAQ

Frequently asked questions

Q. How about the source code in C ?
A. Yes, the source code is available; see the download page.

Q. Can you do a .hex file for X Mhz? (insert a random number at X)
A. In addition to the free bootloader which supports 3.68Mhz and 20Mhz, additional hex files are available for 10Mhz and 40Mhz. As you have the source, you should be able to compile it for any frequency you require.

Q. What are the recommended config bits?

A. Load up the supplied .hex file - the recommended bits are recognized automatically by the programmer.

Q. How much space does the bootloader take up?
A. The bootloader takes up the top 2kbyte out of 32kbyte of code space in a PIC18Fx52, from 0x7000 to 0x7FFF. For Hi-Tech PICC18, add the command '-RESROM7000-7FFF' to reserve space for the bootloader.

Q. Is there a version available for Linux using Python (and possibly Mac)?
A. Yes.


---start email---

Hi

It's a bit of a hack but here is a short python program which may be
useful for Linux enthusiasts.

This program works with the PIC18F452 boot-loader (20MHz clock version)
designed for the TRUTRACK boot-loader interface for Windows. I wanted to
use Linux, so I took a look at the serial data and hacked a quick script
to allow new code to be loaded using Linux instead of Windows.

It always loads a file called main.c and always assumes the port is at
/dev/ttyUSB0. The hex file is assumed to be a standard intel hex file
such as that produced by the HiTech PIC C compiler.  It also requires
PySerial and the USPP serial library. Otherwise it works quite well.
Just copy the desired hex file into the same directory as the python
program, open a terminal and type 'python pyloader.py' in the same
directory.

I haven't tried it but it should also work on a Mac as well....maybe
with a few tweaks.

- Chris Leaver

Download pyloader.py.

---end email ---



This site is non-profit. Ad revenue almost covers hosting costs.

We welcome any suggesions or comments! Send them to Shane Tolmie on support@microchipc.com. This site is a completely separate site to www.microchip.com, and is maintained independently of Microchip Ltd., manufacturers of the PIC micro. All code on this site is free for non-commercial use, unless stated otherwise. Commercial use normally free, however, it is prohibited without contacting support@microchipc.com for permission. All content on this site created by Shane Tolmie is copyrighted by Shane Tolmie 1999-2009. Click to advertise on this website - $29.90 for a banner ad which will reach 55,000 user sessions per month. One months free trial!