Electronics > Microcontrollers

8-bit PIC programmer using an Arduino

(1/1)

jfedison741:
Hello,
I have been using a-p-prog (developed by jaromir-sukuba see https://github.com/jaromir-sukuba/a-p-prog) to program a PIC16LF1902 and it is working fine for smaller code sizes, but as soon as I get above about 40% Flash usage, the code tries to run but then seems to be resetting itself at a certain point (LED blinks erratically instead of at the expected 1 sec intervals).  Even though the a-p-prog loader does not report any errors while loading, the code on the PIC does not run when file size is above approx. 40% Flash. When I load the same code using an old PIC programmer, the code runs fine.

Anyone have experience using a-p-prog to program an PIC16LF1902 (or similar)?

This part allows a max Vdd of 3.6 V so I am using 3.3 V on the Vdd pin of the PIC and also using bi-directional level shifter between the 5 V Arduino and the 3.3 V PIC (on the ICSPDAT, ICSPCLK and MCLR lines). It appears a-p-prog was designed to be used only with 5V/16MHz Arduinos as I could not get it to run with a 3.3 V/8MHz Arduino. I don't think the level shifting is a problem as smaller programs work correctly while larger ones (all using a-p-prog as programmer) don't.

jfedison741:
Update: Problem solved.

After looking at the device file "pp3_devices.dat", it seems the parameters for the PIC16LF1902 part were a bit off. For this part, the flash size is 4096 bytes and the page size is 64 bytes. I adjusted the PIC16LF1902 line of pp3_devices.dat to read:

16lf1902  4096   64 2C20 FFE0 CF_P16F_A

After that I tried to load a large hex file and it now appears to be loading correctly.

(I have not tested any other parts in PIC16LF19xx family but it looks like some of those may also need similar corrections in the pp3_devices.dat file.)

I would submit an update to a-p-prog on github but currently don't know how.

ledtester:

--- Quote from: jfedison741 on October 16, 2021, 01:30:08 am ---I would submit an update to a-p-prog on github but currently don't know how.

--- End quote ---

You can just open up an issue and explain your fixes.

- go to: https://github.com/jaromir-sukuba/a-p-prog/issues
- click on the "New issue" button in the upper right

You might have to be logged into github (i.e. have an account.)

Otherwise you have to clone the repo, make and commit the changes in your repo and then create a PR (pull request) in the original repo.

Here's a video:

- Creating a Simple Github Pull Request -- Jake Vanderplas
https://youtu.be/rgbCcBNZcdQ

jaromir:
Or alternatively, you can contact me here. I'll fix the problem you found, thanks.

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version