battlecoder / zeppp

ZEPPP - Zero External Parts PIC Programmer
http://blog.damnsoft.org/zeppp-zero-external-parts-pic-programmer/
Other
46 stars 18 forks source link

PIC 16F887 not being recognized by zeppp #13

Closed Kasama closed 7 months ago

Kasama commented 7 months ago

Hello, first of all thanks for your work on this, it is surely a very useful resource for programming PIC micro-controllers.

I am having an issue with my setup with a PIC16F887, I followed the instructions and tried some of the examples, as well as trying to flash a blink.hex I compiled with the mplab ide, they fail with the error saying that it is an Unrecognized device with ID 0x0000.

I am pretty sure the PIC is working, as it has an older program running that works.

This is the complete output of one of the examples. Leaving out -d 16f887 has a similar output, it just omits the line saying that the Pic device was selected.

$ java -jar zeppp-cli.jar -c /dev/ttyUSB0 -d 16f887 -ra -o full_pic_dump.hex
Opening port /dev/ttyUSB0...
Connecting to ZEPPP interface...
-- Interface detected: ZEPPP 1.0.2 20220824
Pic device '16f887' selected
Detecting connected device...
ERROR: Failed to Detect connected device. Unrecognized device with ID 0x0000

The interface detected line makes me believe that the arduino part of zeppp is working properly. Also, while trying to program, the rx/tx leds on the arduino blink, which probably means it is getting the messages from the host.

My wiring from the arduino to the PIC is below. It basically follows the pins in the table from the readme, checked against the datasheet (mine is a 40-pin package. Pins are on page 7 of the datasheet)

IMG_20240218_044258

Kinda hard to get everything in a single shot, but the wires are: green -> arduino digital 6 -> pic RE3/MCLR/VPP orange -> arduino digital 7 -> pic RB7/ICSPDAT brown -> arduino digital 8 -> pic RB6/ICSPCL gray -> arduino digital 9 -> pic RB3/AN9/PGM/C12IN2- yellow -> arduino 5V -> pic VDD black -> arduino GND -> pic VSS

I would love to know if you have any insights as to what's going on or how can I further debug this. Thanks again!

battlecoder commented 7 months ago

Hi. Have you tried connecting all VDD and VSS pins? That IC has two sets of VDD/VSS pairs; one on each side of the IC package. In my testing I always connect both sides. This might be a requirement of some specific parts and not universal advice, but ever since I started using PICs, like 20 years ago, PICs with power supply pins on both sides needed both sides to be powered to work correctly. Again; this might not be the case with ALL PICs or microcontrollers, but I know from first-hand experience that some will not work with only one side connected.

Try that if you haven't already.

Regards,

Kasama commented 7 months ago

That is a great bit of knowledge I wouldn't have thought of, thanks.

Unfortunately, it didn't make a difference in my case. The programmer still states that it has an Unrecognized device with ID 0x0000.

If you have any more tips that might help here I'm happy to hear.

Thanks again, Regards

battlecoder commented 7 months ago

Sorry to hear that it didn't work. I'm a bit curious about how is the interface being detected successfully on a Duemilanove (which should also implement the automatic reset that the Arduino Uno implements), without the wait command. Can you try adding "-wait 2000" (no quotes) after "-c /dev/ttyUSB0" ?

EDIT: My reasoning here is that maybe on linux the serial port works in a different way and it's not causing a reset on connection but maybe on first command sent.

Kasama commented 7 months ago

got the same result both ways

$ java -jar zeppp-cli.jar -c /dev/ttyUSB0 -wait 2000 -ra -o test.hex
Opening port /dev/ttyUSB0...
Waiting 2000 ms ...
Connecting to ZEPPP interface...
-- Interface detected: ZEPPP 1.0.2 20220824
Detecting connected device...
ERROR: Failed to Detect connected device. Unrecognized device with ID 0x0000

$ java -jar zeppp-cli.jar -c /dev/ttyUSB0 -ra -o test.hex
Opening port /dev/ttyUSB0...
Connecting to ZEPPP interface...
-- Interface detected: ZEPPP 1.0.2 20220824
Detecting connected device...
ERROR: Failed to Detect connected device. Unrecognized device with ID 0x0000

It's possible that the serial port works a bit differently between OSs, but it seems to be able to send the initial command and get a response at least, so communication seems to be working

battlecoder commented 7 months ago

Yeah, and your wiring seems ok from what I can see. Do you have access to a Windows box or VM? maybe it's a problem of line ending between commands or something (CRLF issues), which is a typical linux vs windows issue. I can try on a linux box after I'm done with a couple of things here, but if you can test that before I do, that'd be helpful.

Kasama commented 7 months ago

alright, I dug up an old notebook that has windows on it and after waiting for many minutes of updates I ran ZEPPP on it on COM3 (I checked the arduino port on device manager) and got the exact same result. I also tried specifiying the device with-d 16f887 with the same result.

Although it is the same, this was the output

Opening port COM3...
Waiting 2000 ms ...
Connecting to ZEPPP interface...
-- Interface detected: ZEPPP 1.0.2 20220824
Detecting connected device...
ERROR: Failed to Detect connected device. Unrecognized device with ID 0x0000
Kasama commented 7 months ago

do you know of a way I can test that the flashing on this PIC is working? I know the controller itself and ports are, because it was working in an application for a few years and I'm looking into this project cuz I lost the programmer I last used and wanted to update it for a new use case.

Kasama commented 7 months ago

I tried some commands on the arduino ide serial console and got the following results. It seems that the PMR command is not returning anything.

I see that both LVP and EXT don't get any confirmation from the PIC and just returns OK.

I tried a PMR with 0x20, which seems to be to read the PGM memory and it also returns nothing.

I dug a bit but didn't find a good command that I can send to check if the PIC is responding.

> FWI
OK: ZEPPP 1.0.2 20220824
> PMR 0x1
OK: 
> FWI
OK: ZEPPP 1.0.2 20220824
> LVP
OK: Entering LVP Programming Mode (Legacy method)
> PMR 0x20
OK: 
> EXT
OK: Exiting LVP Programming Mode
battlecoder commented 7 months ago

Sorry it took me a while to reply back, I was gathering some components to replicate your setup. I got an Arduino Diecimila (which is the closest I have to a Duemilanove, and they are listed under the same setting on the Arduino IDE), a 16F887, breadboard and wires. I downloaded the jar and firmware from the repo (to avoid using any local version that might be different), and set up everything on the breadboard like you did.

So, a couple of things worth noticing: 1.- Without applying power to both sides of the PIC, I also got the "unrecognized device" with id 0x0000. This normally indicates that the PIC is not responding to the identification command, which also makes it quite likely that it will not respond to anything else (that seems to be what you are experiencing with the empty PMR read). 2.- I had to add the -wait command. Maybe this is due to the difference in the arduino I'm using, or a difference in the operating system. I don't think this is important; as long as you got the interface to reply like you did, this shouldn't make any difference. 3.- With the wait added, and connecting both sets of VDD/VSS it worked well for me.

It would be great if you can either try a different PIC with ZEPPP or try the PIC with a different programmer. I suspect that your PIC is either dead, OR maybe when it was programmed someone disabled LVP (Low-voltage programming). When you program a PIC with HVP (High Voltage Programming) you have the option to disable LVP. If you do, you won't be able to program the device in LVP mode unless you enable that capability again (which can only be done with an HVP programmer).

Kasama commented 7 months ago

Thanks a lot for replicating the setup, that basically confirms it's a problem on my end hahaha.

I didn't know it was a thing, but it is possible that LVP got disabled last time I programmed it (honestly don't remember, it's been a while). Last time I programmed it it was certainly using the HVP method, cuz I remember some warnings about the 13V line going to MCLR.

Once again, thanks for taking the time to help me with this. I'll try to get my hands on an HVP programmer (or make one with an arduino using some other project).

Great work on this project btw, if I can reprogram the pic, I will certainly use zeppp in the future, as the board I have the PIC living normally has ICSP headers and it will be easy to setup.

Have a great one! I will close this as it doesn't seem to be a problem with zeppp itself :smile:

battlecoder commented 7 months ago

No problem. I wish you the best, and thanks for your kinds words. I hope you can use ZEPPP in a future. PICs are incredibly fun!