4442

As part of the software download for the book “Programming the Finite State Machine” there is a program to allow an FTDI lead TTL-232R-5V-WE to be used to program the 12F1822 and 16F1823 PICs. This project updates the Linux version of the software to give an increase in write speed of around 1600%, and an increase in read back of around 17%.

As part of the software download for the book “Programming the Finite State Machine” there is a program to allow an FTDI lead TTL-232R-5V-WE to be used to program the 12F1822 and 16F1823 PICs. This project updates the Linux version of the software to give an increase in write speed of around 1600%, and an increase in read back of around 17%. The reason for the huge increase in write speed is that the original program was written with reliability in mind as I didn’t want the reader to have any problems so the first version was a lot slower than it might have been. The original could only transmit one bit per millisecond this version transmits bigger chunks per millisecond. The much smaller increase in read back speed is because there is a  read/write for each bit.

Using the Write Program
The program makes use of the low voltage in circuit programming facility.
No installation is required other than libftdi1 needs to be installed first. If you are using Debian or a derivative such as Ubuntu it can be installed from the command line with:     sudo apt install libftdi1-dev
If you are using Fedora:     dnf install libftdi

The only hardware you need is a USB FTDI lead part number TTL-232R-5V-WE .
The wires are colour coded and are used as follows:
  • Red - 5 V Pin 1 on the 16F1823 and Pin 1 on the 12F1822
  • Black – 0 V Pin 14 on the 16F1823 and Pin 8 on the 12F1822
  • Yellow – ICPDAT Pin 13 on the 16F1823 and Pin 7 on the 12F1822
  • Orange – ICPCLK Pin 12 on the 16F1823 and Pin 6 on the 12F1822
  • Green – nMCLR Pin 4 on the 16F1823 and Pin 4 on the 12F1822

Connect the lead to you project,, while programming the PIC only use the 5 V from the lead not from any other supply.

The executable file program_writer can be copied to any directory that you are using that has the .hex file in it.

At the command line use: ./program_writer your_program.hex
If you prefer the executable can be copied to  /usr/local/bin  and can be called from anywhere by typing program_writer without the ./ infront.

You might have to change the file permissions to allow the program to be run by typing this at the command line while in the directory with the file:    sudo chmod +x program_writer

Using the Read Program
The read program use is exactly the same. It reads back the flash memory and compares it with the .hex file.If any difference occurs it flags up the error in its print out.

Option to compile from Source
If you would rather not use the executables provided but compile them yourself the source code is provided along with a compile script. Also the executables provided here are for 64 bit systems so you will have to do this if you are using a 32 bit system. You will need to have a C compiler installed. In the case of Ubuntu this can be done by installing the build-essential package.

Screendumps
For Screen dumps see Fig1. These were from calling the programs from /usr/local/bin .