Using PicStart Plus under Linux

Submitted by martyn on Thu, 13/04/2006 - 16:47

Microcontroller development under Linux at times is still a little problematic. Many applications exist to enable compiling of C, assembly language and for programming many different microcontrollers. Here we will consider how to program Microchip's PIC family of microcontrollers.

Programming

To program a microcontroller two aspects need to be in place:

  1. A hardware programmer
  2. A software driver for the programmer

Hardware

There are a large number of programmers available for the PIC microcontroller range. However, most of these devices only have software available for windows. A number have open source projects aiming to provide drivers for many of these programmers exist but generally these do not support the same breath of devices. Fortunately Microchip, the maker of the PIC range of microcontrollers, also produces a serial programmer, the PicStart Plus.

Software

The PicStart Plus has a reasonable good open source driver called picp, this driver supports a large variety of Microchip's devices. Once compiled, this application allows Intel Hex files to be transfered to the microcontroller.

Assuming that the PicStart Plus is connected to the first serial port (/dev/ttyS0) and the pic18f252 microcontroller is being used, the following command can be used to erase the microcontroller:

picp /dev/ttyS0 18f252 -ef

The hex file (using the name "flash.hex" as an example) can be transfered with the following command:

picp /dev/ttyS0 18f252 -bp -wp flash.hex

The following example Intel Hex file, flash.HEX (zipped), which has been compiled for the PIC18F252, will cause Pin A4 to raise and lower. At a 20MHz clock speed, this will occur at a frequency of approximately 1Hz.