Simple Pic Programmer (for 68k Mbc and Others)

by coopzone in Circuits > Arduino

623 Views, 1 Favorites, 0 Comments

Simple Pic Programmer (for 68k Mbc and Others)

IMG_4613.JPG

This project combines information / software from several placed on the web into instructions on how to build a simple pic programmer. It is designed for use with the 68k-mbc SBC computer (it is possible to program other PIC chips, BUT this is NOT a Pickit! or a SNAP programmer). It should work with most 16, 18 series MODERN Low Voltage programmable PIC MCU's, 8 bit chips. It does not work with older chips!

So far I have tested it with the following PIC chips:

18f47q10. Used by the 68k-mbc The main reason behind this project.16f18444  Used is some of my other projects (see train speedo etc)16f18445. as above16f18344. For testing code16f18345. For testing code

I can't vouch for other chips the original authors page for the PP sketch and programming software lists many more it should work with, but I have not confirmed them, see https://github.com/jaromir-sukuba/a-p-prog

Note: the 18f47q10 device ID on the project home page (above) is broken. This was fixed by just4fun the creator of the 68k-mbc (and others). He also enhanced the PP Arduino sketch by adding a switch to "pause the boot", putting the software into Stanbt mode (STBY). Allowing time to connect the PIC chip etc.

The softer from GITHUB (original or the corrected/enhanced version) contains both a windows version of the programmer software and a linux version. I will be using the linux version, but will try to mention the windows equivalent where I can. I don't have a Windows based machine so you may need to check the links in the supplies section to find further instructions.

DISCLAIMER: Use at your own risk no responsibility accepted for use or abuse of this program/hardware.

Supplies

You will need the following,

Any Arduino (based on a 328P AVR chip), things like duemilanova, Uno etc, mostly the older boards or clones.

Either a breakout board with 4x470ohm and a switch OR a PCB board shield (either the onedesigned by Just4fun, see the 68k-mbc home page. Or I have some small PCB shield made up with a cable listed on ebay.)

A copy of the files from https://github.com/coopzone-dc/simple-pic-programm...

(these are the corrected files by Just4fun and my version of the Arduino shield PCB Gerber files and circuit)

Bellow are links to the original sites for information (worth a read)

https://github.com/jaromir-sukuba/a-p-prog a-p-prog Uno sketch and linux/windows software

https://hackaday.io/project/8559-microchip-pic-ard... further info on above project.

https://hackaday.io/project/177988-68k-mbc-a-3-ics... Some useful instructions on programming the 68k-mbc pic.

https://www.instructables.com/Model-Train-Speedome... One of yy other projects on instructables using this programmer.

Programming the Arduino

IMG_4612.JPG

I make the assumption that you have a working setup based on the popular Arduino IDE software.

After you download the pp-software zip file from https://github.com/coopzone-dc/simple-pic-programm...

unzip it to your Arduino protects folder, on my linux machine it's a folder in my home directory called Arduino.

for example from a Shell prompt:

cd ArduinoUnzip a-p-prog-master.zip

From inside you Arduino IDE, locate the the fw folder then open the pp folder, finally the pp.ino sketch.

Check you have the correct Board selected in tools, board menu (probably Arduino Uno)

Check you have the correct Serial port tool, port

Now upload the sketch to your board. If you have the shield connected and the switch in the STBY position the onboard LED will be flashing. This indicates the sketch has loaded ok and is waiting for you to flick the switch.

ICSP Shield or Breadboard

IMG_4605.JPG

Important: You should connect everything up ready with the power off.

The ICSP shield is in RUN mode with the switch pushed toward the ICSP connector (as in the above photo) and in STBY mode if pushed the other way, away from the ICSP connector. STBY is also indicated by a flashing LED on the Arduino (you may need to press reset to see this).

If your using breadboard, make up the circuit (as supplied from the GITHUB site) using suitable dupont cables to connect to your 68k-mbc (or other PIC board). You don't actually need the switch - just use one jumper lead to the ground rail and manually plug in in/out to simulate the switch.

If your using the shield (any version) plug it in and connect the ICSP cable to it, any 5/6 pin female to female cable will be ok. You only use pins 1-5 anyway.

Make certain you have the connections correct, double check it. Remember you only need 1-5 connected Pin 6 is not used. Only power up when you have checked at least three times!

You can now power up with the switch closed on in the STBY position. You will get the LED flashing on the Arduino. Try opening the switch (RUN position) the LED should go off.

For now return the switch to "On" or hold, then press reset on the Arduino board. Make sure the LED is flashing.

Compile PP3 (optional)

Compile the pp3 program. You may not need to do this step! the directory sw in the zip file you downloaded and unzipped contains two versions of pp3

The linux version is called pp3 and was compiled for libc v6. It may well work without compiling it from source. Bellow is a ldd listing for the pp3 linux version.

ldd pp3linux-vdso.so.1 (0x00007fff78510000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f321549b000)/lib64/ld-linux-x86-64.so.2 (0x00007f3215705000)

The windows version pp3.exe is pre compiled and works on 32bit or 64bit windows.

If you really need to compile it...

Again from within the sw directory, make sure ppp.c is in the directory. You may need to install the C compiler for your system (it's out of scope for this instructable)

run:

cc -o pp3 pp3.c

The above should run without error and will produce or overwrite the pp3 program file

Test the Connection to the PIC

IMG_4607.JPG

I'm assuming you are using this for a 68k-mbc. If you are using another PIC chip change the name in the commands bellow to the correct one.

DO NOT power the 68k-sbc (or other project) from a separate power source while this programmer is connected to it. Power is supplied via the shield (this differs from the just4fun instructions). It is ok to have the TTY-USB serial cable plugged in to the same computer as the programmer.

You need to be at a Shell (command prompt) and in the directory that contains the pp3 or pp3.exe. Should be the sub directory "sw"

Once everything is powered up (the target board and the Arduino). Switch the Shield to RUN or open the switch.

Now try the following command. It's essentially the same in windows, but the port name will be different COM4 or whatever.

./pp3 -c /dev/ttyUSB0 -s 1700 -p -n -t 18f47q10PP programmer, version 0.99Sleeping for 1700 ms while arduino bootloader expiresDevice ID: 70e0 

If you get error messages check you connections! Also the serial port is the correct device name.

Program the PIC

IMG_4608.JPG

Assuming everything is ok to this point, you should be good to go..

Make certain you are in a directory with the pp3 program in it (windows or linux), normally the sw sub-directory of a-p-prog-master.

When you run this command you need to be careful to get the path to your HEX file. For example on my linux system, if I have downloaded the latest HEX file for the 68k-mbc and it saved it to my downloads directory I would do:

./pp3 -c /dev/ttyUSB0 -s 1700 -t 18f47q10 /home/derek/Downloads/S310121-R220721_68k-MBC_IOS.X.production.hexPP programmer, version 0.99Sleeping for 1700 ms while arduino bootloader expiresDevice ID: 70e0 Programming FLASH (131072 B in 1024 pages per 128 bytes): 245 pages programmedProgramming configVerifying FLASH (131072 B in 1024 pages per 128 bytes): 245 pages verifiedVerifying config...OK

You should have no error and it will finish with an OK.

That's it! Once it's done. Turn all the power off disconnect the cables. Test the programming has worked ok.