Close
0%
0%

Microchip PIC Arduino based programmer

I love to program programmers. Yo dawg...

Similar projects worth following
This is more software than hardware project running on vanilla Arduino, but for sake of completeness I'm going to build simple dedicated hardware instead.
More to come.

For #Micro progmeter project I want to deliver full set of open-source materials, but it would be shame if folks trying to replicate the project would have to buy another programmer to flash the PIC MCU, so I decided to do a little bit of brain stretching and implement PIC16F1xxx programmer with... Arduino, just because it is low cost and available platform.

Together with SDCC compiler this serves as completely open-source basis for PIC16F1xxx and similar projects.

The current project status: Programmer working, sources need cleanup.

SUPPORTED DEVICE LIST - see readme at github

  • 1 × ATmega328P Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × Crystal 16MHz
  • 1 × FT232RL Semiconductors and Integrated Circuits / Misc. Semiconductors and Integrated Circuits
  • 2 × LED 0805
  • 6 × 470Ohm resistor

View all 9 components

  • version 0.99

    jaromir.sukuba06/28/2018 at 11:17 1 comment

    Support for new PIC18FxxQ10 is added (by the way, its FLASH is programmed in different way than most of the other new PIC16 and PIC18 devices, thank you Microchip for another programming algorithm to implement), now it's 439 devices in total. It looks like there are no other LVP programmable 8-bit PIC devices, so probably I can polish it and release version 1.00 soon.

  • version 0.98

    jaromir.sukuba06/19/2018 at 13:13 0 comments

    As usual, on github.

    I added some new devices - PIC16F184xx, PIC18FxxK40 and PIC18FxxK42, support list having 433 entries by now.

    Also, programming speed for some devices is increased.

  • version 0.97

    jaromir.sukuba06/18/2018 at 11:59 1 comment

    60 new devices from PIC16F153xx, PIC16F183xx, PIC16F188xx and PIC16F19xxx added, resulting in support for 379 devices in total. For a moment, I'm adding support for new MCUs faster than Microchip can develop them, neat!

    I tested 5 new ones, resulting in 52 MCU types tested.

  • version 0.96

    jaromir.sukuba06/17/2018 at 23:11 0 comments

    After nearly two years, I refreshed this project again.

    Apparently, Microchip introduced new programming specification for newer PIC devices, like PIC16F1xxxx and PIC18FxxK20 and PIC18FxxK22. The old format was LSB first, either with mix of 8/14 bit long words (for PIC16Fxxx) or 8-bit long words, but a lot of direct instructions entering (PIC18). This seems to be unified now (see the famous XKCD comics) with MSB-first and 8-bits only words. Nice initiative, only if there were already a few different formats among PIC devices.

    Honestly, I was too lazy to implement it, but there is already quite a few "new format" devices in the wild, so I finally got myself to add it to pp3 programmer, so here you go. Only PIC16F188xx are added, but more will follow.

  • pics of PICs, version 0.95

    jaromir.sukuba09/16/2016 at 11:15 1 comment

    Today I made some more progress. I added support for more PIC18FxxKxx devices, so the total supported devices count is 305. There will not be much more of them.

    I tested a few new ones, including PICs in TQFP package. Unlike for DIP packages, breadboard and wires are not enough, so I had to use TQFP adapter I made few years ago for PIC24 and PIC32 series, but with single cut trace it works for PIC18 too.

    There is nothing more than micro and decoupling caps. By the way - JS09 really means year 2009. The time flies.

    For this adapter I made simple testbench of perforated PCB.

    With this one I tested PIC18F66J15, 67K22 and 67J50, each on its own breakout.

    And this is gallery of all PIC devcies I programmed with this Arduino programmer. Every single MCU here has blink a LED program flashed. Much blinking power, very wow.

  • version 0.94 - PIC18FxxKxx CAN devices added

    jaromir.sukuba09/14/2016 at 16:42 0 comments

    In version 0.94 I added support for CAN devices like PIC18F25K80, 12 new in total. New firmware is released too.

    Everything is on github.

  • version 0.93

    jaromir.sukuba09/12/2016 at 09:28 0 comments

    I hunted a bug with programming PIC18F24J10, but finally I got it working - so version 0.93 is out.

    I ordered some more PIC18FxxJxx devices to test the programming protocol implementation. After tested, I'm going to do the final sources cleanup and release version 1.00.

    Files are on github, as usual.

  • Version 0.92 - major rework

    jaromir.sukuba09/09/2016 at 11:14 0 comments

    I reworked the MCU selection code. The if-then structure was OK for dozen of devices, but with more than 200 supported MCUs, it became messy. So I rewrote it into simple plain text file database with entries like

    # PP3 device database for version 0.92
    # 
    # name   flash page  ID  mask family_type
    # flash size and page size in bytes 1 WORD = 2 BYTES
    # 
    # PIC16 family
    16f1503   4096   32 2CE0 FFE0 CF_P16F_A
    16lf1503  4096   32 2DA0 FFE0 CF_P16F_A
    16f1507   4096   32 2D00 FFE0 CF_P16F_A
    16f1508   8192   32 2D20 FFE0 CF_P16F_A
    16f1509   16384  32 2D40 FFE0 CF_P16F_A
    16lf1507  4096   32 2DC0 FFE0 CF_P16F_A
    16lf1508  8192   32 2DE0 FFE0 CF_P16F_A
    16lf1509  16384  32 2E00 FFE0 CF_P16F_A
    16f1454   16384  64 3020 FFFF CF_P16F_A
    16f1455   16384  64 3021 FFFF CF_P16F_A
    ...
    ...
    so it is easy to edit (add new PIC devices or fix mistakes in existing) by hand without recompiling the code. The pp3 takes all the information about device to be programmed from here. The original source shrunk from 2700 to 900 lines of code.

    I also added 67 more PIC18FxxJxx devices and one PIC16F, so it supports 273 devices in total. At last, I tested support for another 7 devices, all of them working on a first try. I feel like time for 1.0 release is near.

    Everything is on github, as usual.

  • After 0.9 comes 0.91, obviously

    jaromir.sukuba09/06/2016 at 12:16 5 comments

    I decided to release version 0.91 - the previous should be 0.90, then.

    No matter what, I added some more devices - 205 devices supported in total.

    I also changed somehow serial port handling, resulting in higher programming speed, especially under windows. PIC16 programming algorithm got a bit more intelligence, resulting in faster programming.

    Before 1.00 release I'd like to rework the MCU type selection into table driven function instead of huge if-then-else behemoth and set support for all LVP ICSP-able 8-bit PIC devices.

    Everything is at github, as usual https://github.com/jaromir-sukuba/a-p-prog

  • Version 0.9 - 175 devices supported

    jaromir.sukuba09/05/2016 at 20:55 0 comments

    Oh here we go, version 0.9 - this means first "normal" release 1.0 is close.

    I added a lot of new devices, some new are tested. I fixed some bugs around serial port and hex file handling. The PIC name is now case non-sensitive. 175 devices is in support list in total.

    Everything is on github, as usual.

View all 24 project logs

Enjoy this project?

Share

Discussions

alexbladex wrote 05/16/2022 at 14:56 point

Hi!  I am interested in your project. Please tell me you have implemented the ability to read the firmware?
if not. could you do it in the next version 1.0 ?

  Are you sure? yes | no

Juan David wrote 09/19/2021 at 16:16 point

first of all, I want to greatly thank you for sharing this project with us.

I'm using Arduino Mega 2560 to program a pic 18f5k50 but I'm getting an error that I have not been able to solve. I would appreciate help :D

I took  a look into the arduino code in order to make myself with some clues but I had no success, there was no much that I could understand.

This is the output of the terminal after running pp3 ( I placed the hex file in the sw folder )

juan@juan-pc:~/Desktop/a-p-prog-master/sw$ sudo ./pp3 -c /dev/ttyACM0 -t18f45k50 -s 1700  Mne.X.production.hex 
PP programmer, version 0.99
Sleeping for 1700 ms while arduino bootloader expires
Wrong device ID: 0000, expected: 5c00
Check for connection to target MCU, exiting now
juan@juan-pc:~/Desktop/a-p-prog-master/sw$ 

I'm guessing that somehow the pp3 script is having issues to get device id from the device.dat file, but thats just a hunch, I have no technical reason to say that.

EDIT: 

When running the same commad as above as root user, the terminal output log changes a bit, here it is:

juan@juan-pc:~/Desktop/a-p-prog-master/sw$ su
Password: 
root@juan-pc:/home/juan/Desktop/a-p-prog-master/sw# ./pp3 -c /dev/ttyACM0 -t18f45k50 -v Mne.X.production.hex 
PP programmer, version 0.99
Serial port failed to receive a byte, read returned 0
/dev/ttyACM0: Success
Aborted (core dumped)
root@juan-pc:/home/juan/Desktop/a-p-prog-master/sw# 

  Are you sure? yes | no

olfresh-cf wrote 04/27/2022 at 18:32 point

Hi. , I also get an error for 18f25k80 (Wrong device ID: 0000). Did you manage to defeat the bug?

  Are you sure? yes | no

Just4Fun wrote 04/17/2021 at 14:30 point

Hi, I've successfully used your programmer on linux (with a common Arduino UNO) to flash a PIC18F47Q10!

Please note that the Device Id of PIC18F27Q10 and PIC18F47Q10 are exchanged, so I've corrected at first them in your "pp3_devices.dat" files.

I've also noticed that  the MCLR/VPP pin (A3) is normally at HIGH level. This can be an issue when connecting your programmer to self-powerd boards. I've checked on both the MPLAB Pickit 4 and MPLAB SNAP programmers and they leave the MCLR/VPP pin at GND or 3-stated.

So I've modified your .ino and added a small switch on A2 so I can put your programmer into a "stand-by" state with all the ICSP pin at GND (or 3-stated) . This allows to connect safely the ICSP cable with an un-powered target board while the Arduino Uno is powered. Then I can power the target board and change the position of the switch to let  the programmer operate as intended.

After the programming I do in sequence: set the switch to "stand-by" again, reset the Arduino UNO, un-power the target board, disconnect the ICSP cable, and finally un-power the Arduino UNO.

Here the changed part at the beginning of your "int main" function:

.....

int main (void)
{

  pinMode(13, OUTPUT);
  pinMode(A2, INPUT_PULLUP);
  while (digitalRead(A2))
  {
    digitalWrite(13, HIGH);
    _delay_ms(200);
    digitalWrite(13, LOW);
    _delay_ms(200);
  }

.....

The blinking Led of the Arduino UNO is used to give the feedback that the programmer is in the "stand-by" state, and the connection or disconnection to/from the target board is safe.

Thanks for this beautiful programmer!

I'll use it to give a simple and cheap way to program the PIC18F47Q10 MCU used inside my 68k-MBC board.

Here a couple of images of my Arduino Uno and the "ICSP Shield":

https://i.postimg.cc/L4PDWjcP/20210417-155447.jpg

https://i.postimg.cc/zvTkR1C7/20210417_155718.jpg

Regards.

J4F

  Are you sure? yes | no

repetto.riccardo wrote 03/20/2021 at 20:13 point

Hi. 

I have flashed a PIC 16f1826 but I'll get this error : 

C:\Users\Desktop\a-p-prog-master\sw>pp3.exe -c COM4 -s 1700 -t 16f1826 16f1826.hex

PP programmer, version 0.99

Sleeping for 1700 ms while arduino bootloader expires

Device ID: 2780

Programming FLASH (4096 B in 256 pages)

Programming config

Verifying FLASH (4096 B in 256 pages)

Verifying config

config 2 error: E:0x3DFF R:0x1DFF

What this could be? I am using an arduino nano not your programmer.
Show less

REPLY

  Are you sure? yes | no

k8lh wrote 01/03/2021 at 07:11 point

Cystor is awaiting your reply in ISSUES section on Github...  I would very much like to try his GUI front end for your A-P-Prog.

Cheerful regards, Mike

  Are you sure? yes | no

k8lh wrote 12/21/2020 at 20:49 point

Greetings Jaromir.  I cannot thank enough for sharing your hard work and esoteric knowledge with us mere mortals (grin).  May I ask if it would be difficult to update supported devices to include the 'Q43' clan?  

Stay safe.  Happy Holidays and cheerful regards.  Mike

  Are you sure? yes | no

jaromir.sukuba wrote 12/22/2020 at 01:01 point

Hello,

I took a look at programming specs of Q43 and unless I overlooked some nasty detail, it should have the same programming protocol as some other newer PIC 8-bitters, so I think Q43 (and other Qxx for that matter) should be relatively easy to add.
I have some other TODO work at this project, so as soon as I get the Qxx parts in my hands I'll try to add support to those and release new version.

  Are you sure? yes | no

k8lh wrote 12/28/2020 at 06:27 point

Thank you Sir.  Could you peek at 18F16Q40/Q41 devices too, please?

Cheerful regards, Mike K8LH (Michigan, USA)

  Are you sure? yes | no

Piotr wrote 12/08/2019 at 09:38 point

I would like to download program form this project to PIC16F1788

http://kair.us/projects/weller/index.html

I have downloaded the program with success to uC with pickit3, but when i try to use Your programmer i always get such error: 

config 2 error: E:0x3AFF R:0x1AFF

Exiting programming mode

What could be the reason?

What is the proper format of input file bin or hex, what format of Hex? (8, 16 32 bit?) Analyzing the code is hex but in the example is hex or bin?

  Are you sure? yes | no

Joseph Tannenbaum wrote 08/24/2019 at 18:01 point

Finally tried this on a windows 7 32 bit machine.  My chip was supposed to be a 16f1619, but pp3 said the device id was 16lf1619, but it programmed ok.  Thank you.

  Are you sure? yes | no

Olivier wrote 09/16/2019 at 04:49 point

Could you share the pinouts you used? did you add any resistors or just wired the arduino pins directly to the PIC pins?

  Are you sure? yes | no

Joseph Tannenbaum wrote 03/04/2020 at 22:38 point

Sorry, didn't see this till today.  Yes, just wired to the arduino pins.

  Are you sure? yes | no

Joseph Tannenbaum wrote 08/24/2019 at 00:42 point

Was exited to try this only to find out that pp3.exe won't run on my 64 bit machine (windows 10)

have you an exe for 64 bits?  Thank you.

  Are you sure? yes | no

Olivier wrote 09/16/2019 at 04:48 point

it does run. Regardless, I have not been able to make it recognize my arduino/PIC

  Are you sure? yes | no

Joseph Tannenbaum wrote 08/23/2019 at 23:03 point

I know this is not a new project, Is your little programmer card on sale somewhere?

  Are you sure? yes | no

Joseph Tannenbaum wrote 03/04/2020 at 22:39 point

It would be cool to be able to buy one of these little programmers. 

  Are you sure? yes | no

Olivier wrote 06/19/2019 at 06:40 point

I'm trying to use this programmer to program a PIC12F1840 (which is in the supported PICs list) but I cannot get it to work and cannot figure out if I have the right pinouts. The way I have the PIC wired to my arduino nano is:

Arduino:    PIC:

GND       Pin 8 (vss)

5V          Pin 1 (vdd)

A3          Pin 4 (MCLR)

A1           Pin 7 (SDO  (DT?) )

A0          Pin 6 (vss  (CLK?) )

I'm powering the arduino and PIC using my computer's USB port (plugged into the arduino) and when I try to execute "pp3.exe -c COM9" I get:

PP programmer, version 0.99
Serial port failed to receive a byte, read returned 0
COM9: Permission denied

Any help will be appreciated.

Note: I did not use any resistors to limit current to the PIC pins because it wasn't mentioned in the GitHub guide https://github.com/embhobbb/a-p-prog

  Are you sure? yes | no

Olivier wrote 06/21/2019 at 18:29 point

I found my problem. I skipped the part that says that you have to inject some code in your arduino to allow it to work as a programmer. I was digging on the project resources, found the .ino file under https://github.com/embhobbb/a-p-prog/blob/master/fw/pp/pp.ino and uploaded it to my Arduino successfully.

Now the problem I have is that when I run pp3.exe on port COM9 (my arduino port) I'm getting:

PP programmer, version 0.99
Device ID: 0000

Any help will be appreciated

  Are you sure? yes | no

Olivier wrote 08/21/2019 at 09:01 point

@jaromir.sukuba any help will be appreciated. I'm still getting "0000" as the device ID:

C:\Users\Olivier\Desktop>pp3.exe -c COM9 -s 1700
PP programmer, version 0.99
Sleeping for 1700 ms while arduino bootloader expires
Device ID: 0000


https://1drv.ms/u/s!Asv5yaQakrNSiM5mOJzZM3U2thFEEg?e=217iCw

  Are you sure? yes | no

Z900 PhotoTime wrote 01/01/2020 at 01:41 point

I've the same issue now, did you solved it ?

  Are you sure? yes | no

ntembed wrote 05/13/2019 at 10:39 point

Hi, I wonder if I can program with Your programmer PIC16f690?

  Are you sure? yes | no

Olivier wrote 08/21/2019 at 08:52 point

It should work. It is not in the supported PICs list, but PIC16f690 has a pinout pretty much identical to PIC16F1619, which is supported by this programmer.

  Are you sure? yes | no

ep.hobbyiest wrote 11/03/2018 at 13:24 point

Cool Project.
i was trying to flash 16f876a PIC controller but failed. Is PIC16F876A supported?
I am using ATmega168p with 16Mhz arduino.

Do i need to change any thing in code.
Please guide me for the same.

  Are you sure? yes | no

jaromir.sukuba wrote 11/03/2018 at 15:08 point

Thank you.

For Atmega168, AFAIK there are no modifications needed other than recompiling the project for given AVR.

PIC16F876A is not supported and will not be supported, as this is low-voltage (LV) programmer and can't do high-voltage programming without major hardware modifications. This particular PIC is older one, not supporting LV programming

  Are you sure? yes | no

mechtatelnyi1 wrote 12/25/2018 at 13:48 point

2.4.1 LOW VOLTAGE ICSP
PROGRAMMING MODE

Low Voltage ICSP Programming mode allows a
PIC16F87XA device to be programmed using VDD
only. However, when this mode is enabled by a configuration
bit (LVP), the PIC16F87XA device dedicates
RB3 to control entry/exit into Programming mode.
When LVP bit is set to ‘1’, the low voltage ICSP programming
entry is enabled. Since the LVP configuration
bit allows low voltage ICSP programming entry in
its erased state, an erased device will have the LVP bit
enabled at the factory. While LVP is ‘1’, RB3 is dedicated
to low voltage ICSP programming. Bring RB3
and then, MCLR to VDD to enter Programming mode.
All other specifications for high voltage ICSP apply......from datasheet, it does have support of LVP

  Are you sure? yes | no

jaromir.sukuba wrote 12/25/2018 at 14:12 point

@mechtatelnyi1  thanks for datasheet quote. I understood it as question regarding LVP on those parts - this mode requires manipulating PGM pin, either manually or from arduino. Apart from being cumbersome, it results in losing one IO pin; there are much newer parts supported by this programmer, being cheaper, more packed with peripherals and still being pin compatible. Thus, I'm not planning to add support for 16F877 and similar.

  Are you sure? yes | no

KSUdoubleE wrote 08/18/2017 at 17:09 point

Successfully programmed a PIC12LF1571 and PIC12LF1501, worked great.  Thanks!

  Are you sure? yes | no

jaromir.sukuba wrote 08/31/2016 at 13:27 point

@rmessino  The PIC type should be all lower case, like 16f1783, for current software version. Perhaps I should rewrite to accept both letter cases.

  Are you sure? yes | no

adilmalik_n wrote 12/26/2015 at 00:06 point

Can this work with higher end like the DSPIC33F's? ive got a diy dev board that im dying to program and have a PICKIT3 on order but its delayed due to Christmas (dont worry, its a clone).

  Are you sure? yes | no

jaromir.sukuba wrote 12/26/2015 at 14:18 point

Yes, dsPIC33F are technically possible. 

Speaking from memory, all 16- and 32-bit MCUs from Microchip are using low voltage on MCLR and serial key on PGC/PGD pair to enter programming mode (as well as newer 8-bits, like PIC16F1xx, like PIC18F1829 and some PIC18, for example PIC18F46K22 and similar).

On the other hand, there are dsPIC33 with 512kB of FLASH. Programming such as amount of data with this simple and really slow programmer would be pain in the ass. Bottleneck of data throughput here is simple polled firmware architecture and slow serial transfer - acceptable only for few kB of data for 8-bitters.

But it is good to know there is demand for other than PIC16F1xxx devices. I'll start thinking about how to improve the programming speed and scan through programming specs of PIC devcies to determine what types are possible to implement.

  Are you sure? yes | no

Connor Neal wrote 12/10/2015 at 23:37 point

Nice work! Did you hand solder the components?

  Are you sure? yes | no

jaromir.sukuba wrote 12/11/2015 at 09:26 point

Thanks. Yes, I soldered the parts by hand with my DIY soldering iron, leaded solder and cheap chinese flux.

  Are you sure? yes | no

rmessino wrote 08/31/2016 at 03:28 point

Hi first at all, thanks for your work, is great that you are doing. In the ither hand I run pp3 program today I am working with a seeduino board(atm328p) and a pic16lf1783 , I get a error "Unsupported CPU type '16F1783' This application has requested the Runtime to terminate it in an unPlease contact the application's support team for more information." Do you have any idea about?

  Are you sure? yes | no

Blecky wrote 12/07/2015 at 02:40 point

[verified: no design files missing]

  Are you sure? yes | no

alpha_ninja wrote 12/02/2015 at 00:42 point
This is your one-week reminder to upload design documents: https://hackaday.io/project/7813-the-square-inch-project/log/28566-design-deadline

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates