WallaceIT / picberry

PIC Programmer using GPIO connector
GNU General Public License v3.0
40 stars 27 forks source link

Support for pic24fj (PIC24FJ64GA002) #3

Closed eballetbo closed 7 years ago

eballetbo commented 7 years ago

Nice work! I was finding a tool like this to program a PIC24FJ64GA002 and by chance I found your project. I saw that in theory PIC24FJ should work but I've problems trying to read the device id of a PIC24FJ64GA002 device.

picberry -e -g 66,67,60 -f pic24fj
picberry PIC Programmer v0.1
Device ID: 0x0
ERROR: unknown/unsupported device or programmer not connected.

I think your code is based on [2] but the programming specs for my chip is slightly different [1]. At the moment I tried to modify the code to adapt to [1] without luck. Any clue is welcome. Which device did you test?

[1] http://ww1.microchip.com/downloads/en/DeviceDoc/39768d.pdf [2] http://ww1.microchip.com/downloads/en/DeviceDoc/30010057d.pdf

WallaceIT commented 7 years ago

Hi, still not tried with PIC24FJ family, I have a custom board sitting on my desk since March but still not worked on it.

I'll try to look into this on friday, in the mean time: 1) I expect the programming specs to be quite similar. One thing to check is the timings 2) Have you set up a working picberry instance with another PIC? For example a PIC18F24J50?

eballetbo commented 7 years ago

Hi,

  1. Yes, the first thing I checked were the timings, based on [1] I modified the timings, see the attached patch [2]. I think there is also few differences sending the SIX and read code, checking this without success at the moment.
  2. No, is the first time I test this program and I only have a PIC24FJ64GA002 device.

[1] http://ww1.microchip.com/downloads/en/DeviceDoc/39768d.pdf [2] pic24fj-timings.txt

WallaceIT commented 7 years ago

Right, some additional clock cycles are required on first SIX instruction after reset. Unfortunately, I still had no time to check this issue, I hope to find some during this week

eballetbo commented 7 years ago

No problem, I had some few time to look a bit more, I'll try to first read the ID and the configuration words, for some reason still doesn't work (something silly I'm missing that I can't see now) but if you have a pic24fj and want to test I execute the code like this.

picberry -d -g 66,67,60 -f pic24fj_ga0

[1] https://github.com/eballetbo/picberry [2] https://github.com/eballetbo/picberry/commit/80a224f63a6a3559a0fdae467348378c3fd46889

eballetbo commented 7 years ago

Needs more testing but I have a preliminary working version. I am able to erase and program the firmware.

# picberry -e -g 66,67,60 -f pic24fjxxxga0xx

picberry PIC Programmer v0.1
Device Name: PIC24FJ64GA002
Device ID: 0x00000447
Revision: 0x00003046
Bulk Erase...DONE!
Press ENTER to exit program mode...

# picberry -w fw.hex -g 66,67,60 -f pic24fjxxxga0xx

picberry PIC Programmer v0.1
Device Name: PIC24FJ64GA002
Device ID: 0x00000447
Revision: 0x00003046
Writing chip...[[[5DONE! 
Press ENTER to exit program mode...

The code is available here: https://github.com/eballetbo/picberry/tree/topic/pic24fjxxxga0xx

WallaceIT commented 7 years ago

Well done! When you will be confident for this to work, feel free to create a pull request. Thanks!