Summary of PIC18F252 Programming
This article compares two methods to program the PIC18F252: Microchip's In-Circuit Serial Programming (ICSP) and a serial port bootloader found in factory-shipped devices. ICSP clocks data in 20-bit instructions at up to 10 MHz, implying very fast programming but possibly limited by PC parallel-port speed. The author discovered a bootloader in addresses 0000–01BF, enabling COM-port programming; this was verified by disassembling reads and comparing to AN851. Upgrading PICstart®Plus firmware was needed to read the device.
Parts used in the PIC18F252 Programming Investigation:
- PIC18F252 microcontroller
- PC with parallel port (for ICSP testing)
- COM port (serial) on PC
- PICstart®Plus development system
- PIC17C44 (for PICstart®Plus firmware upgrade)
- Firmware upgrade to 3v0 for PICstart®Plus
- Microchip documentation 39576a.pdf (Programming the PIC18FXX2/FXX8)
- Application Note AN851 A FLASH Bootloader for the PIC16 & PIC18
1. Introduction
This investigation was started after I ordered the free sample kit for the Circuit Cellar contest, called Mad Dash for Flash Cash. There seems to be many ways to program the device. Here I have investigated two ways of programming the PIC18F252.
2. In-Circuit Serial Programming™
The Microchip document Programming the PIC18FXX2/FXX8, describes programming either the high or the low voltage In-Circuit Serial Programming™ (ICSP™). This document, 39576a.pdf, is available from the Microchip web site.
Data is clocked with a 10MHz clock maximum, into the PIC, in multiple 20 bit instructions, made up of 4 bits of command, and 16 bits of operand. Between each command and operand is a gap of 20ns and between each block of 20 bits is a gap of 20ns. The operand can contain the word of data payload to be programmed. This might mean the PIC18F252 could be programmed in about 33ms, but it is doubtful that a parallel port on a PC could support that throughput.
3. Serial Port Bootloader
Further investigation into the contents of a “blank”, as shipped, PIC18F252 revealed a program residing from 0000 – 01BF. This code is a serial port bootloader and if allowance for this code is made, then the device can be programmed via a COM port on a PC. The listing for the code is here. I disassembled the object code after reading the PIC18F252 with my PICstart®Plus development system, and comparing the code with that shown in AN851, A FLASH Bootloader for the PIC16 & PIC18. To handle the PIC18F252, the PICstart®Plus needed to be upgraded from 1v5 to 3v0 firmware after obtaining a PIC17C44 from the local supplier.
For more detail: PIC18F252 Programming
- What programming methods are investigated for the PIC18F252?
In-Circuit Serial Programming (ICSP) and a serial port bootloader are investigated. - How fast can data be clocked into the PIC using ICSP?
Data can be clocked at up to 10 MHz per the Microchip document. - What is the structure of ICSP data transfer?
Data is sent in multiple 20-bit instructions composed of 4 bits of command and 16 bits of operand, with 20 ns gaps between fields and blocks. - Can the PIC18F252 be programmed via a PC parallel port using ICSP?
Possibly, but the article notes it is doubtful a PC parallel port could support the required throughput. - What boot code was found in a shipped PIC18F252?
A serial port bootloader was found residing from addresses 0000 to 01BF. - How was the bootloader identified?
By reading the PIC with PICstart®Plus, disassembling the object code, and comparing it to AN851. - Did the PICstart®Plus require any changes to read the PIC18F252?
Yes, it needed a firmware upgrade from 1v5 to 3v0 after obtaining a PIC17C44. - Which documents are referenced for programming details?
The Microchip document 39576a.pdf and Application Note AN851 are referenced.

