|
Installing
the Hi-Tech PICC18 compiler Introduction 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 www.digikey.com. 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 www.microchip.com
- at last count there were 20 devices, one for every situation. 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 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: /* #include <pic18.h> #include "delay.c" 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 - http://www.microchip.com/sourcecode/. 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. If you want to edit these
fuse definitions which you insert into "main.c",
browse to the file "pic18fxx2.h"
in the installation directory Summary As we have seen, getting
started with the PICC18 compiler is quick. Most users will be up and running
in a couple of hours. |