MicroCode Studio
mecanique

 | Index | ICD | Setup | Models | Serial | Sys. Req. |

| Break Points | Toolbar | Edit | WIN | MPASM |

MicroCode Loader Overview
The PIC 16F87x and 18Fxxx(x) series of microcontrollers have the ability to write to their own program memory, without the need of a hardware programmer. A small piece of software (a bootloader) resides on the target microcontroller, which allows user code and EEPROM data to be transmitted over a serial cable and written to the device.

MicroCode Loader

The MicroCode Loader application is the software which resides on the computer. Together, these two components enable a user to program, verify and read their program and EEPROM data all in circuit.

The Bootloader Software

Before using MicroCode Loader, you need to ensure that the bootloader software has been programmed onto the target microcontroller. This is a one off operation, after which you can start programming your target device over a serial connection.

You need to make sure that the bootloader *.hex file matches the clock speed of your target microcontroller. For example, the file 16F877_20.hex should be used to program a device that will be running at 20MHz. If you don't do this, MicroCode Loader will be unable to communicate with the target microcontroller. You don't have to set the baud rate from the main MicroCode Loader application, as it will be detected automatically for you. MicroCode Loader comes with a number of pre-compiled *.hex files, ready for programming into the target microcontroller.

When power is first applied to the microcontroller (or it is reset), the bootloader first checks to see if the MicroCode Loader application has something for it to do (for example, program your code into the target device). If it does, the bootloader gives control to MicroCode Loader until it is told to exit. However, if the bootloader does not receive any instructions with the first few hundred milliseconds of starting, the bootloader will exit and the code previously written to the target device will start to execute.

The bootloader software resides in the upper 256 words of program memory (336 words for 18Fxxx(x) devices), with the rest of the microcontroller code space being available for your program. All EEPROM data memory and microcontroller registers are available for use by your program. Please note that only the program code space and EEPROM data space may be programmed, verified and read by MicroCode Loader. The microcontroller ID location and configuration fuses are not available to the loader process. Configuration fuses must therefore be set at the time the bootloader software is programmed into the target microcontroller.

Hardware Requirements

MicroCode Loader communicates with the target microcontroller using its hardware Universal Synchronous Asynchronous Receiver Transmitter (USART). The PIC 16F87x family of microcontrollers have RX located on PORTC.7 and TX located on PORTC.6. You will therefore need a development board that supports RS232 serial communication in order to use the loader. There are many boards available which support RS232. If the board has a 9 pin serial connector on it, the chances are it will have a MAX232 or equivalent located on the board. This is ideal for MicroCode Loader to communicate with the target device using a serial cable connected to your computer. Mecanique sell a number of development boards which are compatible with MicroCode Loader, including

Alternatively, you can use the circuit shown below and make your own.

Click on image to enlarge...

Connecting a microcontroller to MicroCode Loader
with
optional software reset. Courtesy Reynolds Electronics

Programming Requirements

The bootloader software resides in the upper 256 words of program memory (336 words for 18Fxxx devices), with the rest of the microcontroller code space being available for your program. Because the loader resides upper program memory, it needs a way to 'jump' to the start of the bootloader code when power is first applied, or when the microcontroller is reset. To do this, it uses the first four program words (called the reset vector) to execute a jump to the bootloader code. When you program the target microcontroller using MicroCode Loader, program instructions that occupy the first four locations are automatically relocated by the bootloader. If the bootloader did not relocate these instructions, the important 'jump to bootloader' would get overwritten and the bootloader software would not start next time power was applied or the microcontroller was reset. Therefore, your program needs to be modified to support this process. It's a very simple change, with some examples shown below.

PICBasic Pro, prior to version 2.33

DEFINE ONINT_USED 1

PICBasic Pro, 2.33 and above

DEFINE LOADER_USED 1

Assembler programs can use something like this:

ORG 0
GOTO StartOfProgram

ORG 5
StartOfProgram
; your program goes here

Supported Devices

MicroCode Loader will program all of the following microcontrollers : 16F870, 16F871, 16F873(A), 16F874(A), 16F876(A) and 16F877(A), 18F242, 18F248, 18F252, 18F258, 18F442, 18F448, 18F452, 18F458, 18F1220, 18F1320, 18F2220, 18F2320, 18F4220, 18F4320, 18F6620, 18F6720, 18F8620 and 18F8720. MicroCode Loader comes with a number of pre-compiled *.hex files, ready for programming into the target microcontroller. If you require a free bootloader file with a different configuration, please contact Mecanique.

MicroCode Loader is free when you purchase MicroCode Studio Plus.


Page up-dated at December 16, 2003


GRIFO®
Via dell'Artigiano, 8/6
40016 San Giorgio di Piano
Bologna ITALY

Tel: +39 051 892.052 (4 lines)
FAX: +39 051 893.661


homeHome Index Software Tables Cat. Index