Search this site (

  Installing the Hi-Tech PICC18 compiler


This review explains my experiences when producing code for a 18F252 on a breadboard, after installing the Hi-Tech PICC18 compiler.

Introducing the Microchip PIC18F252

The PIC18F252 chip runs at 40Mhz. It has enough memory (32kb) for approximately 8,000 lines of C. These chips are a pin-compatible and code-compatible replacement for the 16Fxxx microcontrollers, with double the memory and speed.

I purchased a few PIC18F252 chips from These chips cost $US5 in quantity from this particular supplier, and less from other suppliers. I paid with my VISA card, and received a courier package 48 hours later.

I breadboarded this 18F252, adding reset, 40Mhz crystal, and an LED in series with a resistor.

Other chips in the PIC18Fxxx family are available from Microchip - at last count there were 20 devices, one for every situation.

Introducing the C compiler

Hi-Tech C for the PIC18Fxxx microcontrollers is called PICC18. I went to the Hi-Tech C site, and downloaded the demo version of the PICC18 compiler. This compiler supports almost the entire range of PIC18Fxxx micros.

Installing the C compiler

Installing the compiler was a breeze. The new windows installer is very easy to use, and a great advance over the previous DOS based installer.

At that time, the v6.00 beta of MPLab didn't yet have support for Hi-Tech C. Support for Hi-Tech C has since been added in v6.10 of MPLab. For the purposes of this review, I'll explain how I got it working with v5.70 of MPLab.

I selected the menu "Project >> Install Language Tool", then selected "Hi-Tech PICC18" from the language suite. I then browsed to "PICC18.exe" and selected it, as shown in the screenshot below:

This was repeated for the linker, as shown in the screenshot below:

I selected the micro type under the menu "Options >> Development Mode", as shown in the screen shot below:

Next, I entered a simple program, shown below. This sample flashes an LED at 2Hz on the PIC18F452. The code is reproduced here:

Purpose: Flashes LED on RC0 of micro.
Micro: PIC18F252
Compiler: Hi-Tech C18 v8.12PL1 from
Author: Shane Tolmie of DesignREM Ltd.

#include <pic18.h>

#include "delay.c"
    TRISC=0; //set direction of pin 16 on PIC18F252 to output
    while(1) {
        RC0=1; //turn LED on
        RC0=0; //turn LED off

Notice that the code is almost the same as that for a PIC16F877, with the exception of the line "#include <pic18.h>" instead of "#include <pic.h>".

The delay routines (see the line "#include "delay.c") were downloaded off this site -

Next, I hit selected the menu "Project >> Make Project", and the project was successfully compiled.

Programming the Chip

I used a PICStart Plus programmer to program my chip. I selected the manu "PICStart Plus >> Enable Programmer". After the fuse settings came up on screen, I set them manually, according to the 18F252 datasheet. The fuse settings are used to select things like the type of crystal used, or Brown Out Detect (BODEN), which resets the micro if the voltage drops too low.

If I had wished, I could have added the following code to the "main.c", which automatically sets the fuses for programming the chip. If I didn't add these lines into "main.c", then I could set them manually when I program the chip.

//insert these lines before main(){} in main.c to set the fuses for programming automatically
//for freq>8Mhz and <20Mhz, use XT instead of HS for <8Mhz
__CONFIG(2,BORDIS & WDTDIS); //BORDIS=brown out reset disabled, WDTDIS=watch dog timer disabled
__CONFIG(4,DEBUGDIS & LVPDIS & STVRDIS); //DEBUGDIS=debug disabled, LVPDIS=low voltage programmin disabled
__CONFIG(5,UNPROTECT); //unprotected
__CONFIG(6,WRTEN); //flash write enabled
__CONFIG(7,TRU); //all unprotected including boot block

If you want to edit these fuse definitions which you insert into "main.c", browse to the file "pic18fxx2.h" in the installation directory
"C:\HTSOFT\PIC18\include", and copy the correct fuse settings out of these into "main.c"


As we have seen, getting started with the PICC18 compiler is quick. Most users will be up and running in a couple of hours.