Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => Pirate PIC programmer => Topic started by: sirus on December 21, 2010, 08:44:16 am

Title: Pic24fj64gb002
Post by: sirus on December 21, 2010, 08:44:16 am
supposed to work???


Code: [Select]
C:appsbuspirate>piratepicprog.exe -p buspirate -u COM2 -s 115200 -c 24FJ64GB002 -V
(Bus) Pirate PIC Programer v0.2

Initializing interface
115200
Entering binary mode
BP: Setup mode...
Setup peripherals...
(OK)
Found '24FJ64GB002' in programming database :) index = 3
Checking for 24FJ64GB002 attached to programmer...

Wrong device: 0XFFFF (ID: 0XFFFF REV: 0XFFFF)

Code: [Select]
    {
.family = FAMILY_24FJxxGBxxx,
.proto = PROTO_PIC24,
.ID_addr = 0x00FF0000,
.word_size = 2,
.page_size = 256,
.icsp_type = ICSP_LVPP,
.icsp_key = 0x4D434851,
.erase_key = { 0x3f3f, 0x8f8f },
.write_delay = 1, //polled in 24FJ
.erase_delay = 524,
},
Title: Re: Pic24fj64gb002
Post by: ian on December 21, 2010, 04:54:06 pm
That should work. What Bus Pirate firmware are you using? Are you using the PIC programming adapter (probably will only work without it)?
Title: Re: Pic24fj64gb002
Post by: sirus on December 21, 2010, 09:44:17 pm
I'm really just guessing at everything here. ive never worked with pic before, just got my bus pirate on saturday, had to download svn software and a compiler/ide to do just that pic.c mod and i've been pouring through the 352 page datasheet for the pic24fj64gb002 and it's companion programming datasheet for hours that turn into days. Going to give it another go today and see if I can get it up and running. no i dont have the adapter I'm 99% sure this is a low voltage chip. also when setting up the flash mem why is the pic24fj64ga setup as 344*256 ? the other pic was 16*1024 which makes sense to me. btw remember i have no experience doing any of this stuff


oh and now that you mention it i did flash a test firmware someone here flashed. BPv6RC572.hex maybe i should try it again on 5.10
Title: Re: Pic24fj64gb002
Post by: sirus on December 21, 2010, 10:37:26 pm
also is this right? no MISO connection?

Bus Pirate --> PIC
MOSI --> PGD
CLK --> PGC
CS --> VPP/MCLR
GND --> GND
3.3v/5v->power (optional)
Title: Re: Pic24fj64gb002
Post by: Sjaak on December 21, 2010, 10:40:02 pm
If you receive all 1's you prolly swapped the PGC and PGD (just a guess) or make a misconnection. The pic24 has several PGC/PGD pairs IIRC but you need to use PGD and PGC from the same pair.

The trick about the 344x256 is on page 7 of the flash programming spec. It has 344 programming blocks. Each block appears as 256 bytes in the .hex, but in reality it only uses 3 bytes out of 4. This all will result in approx 64k..

Programming spec: http://ww1.microchip.com/downloads/en/D ... 39934b.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/39934b.pdf)

Guess you are right about the miso :)
Title: Re: Pic24fj64gb002
Post by: sirus on December 21, 2010, 10:48:54 pm
GOT IT!! either a loose breadboard con or something, I connected both MISO and MOSI to PGD just to double check lol. It came back with wrong device id, and I'm sure I just messed up the ID code myself so I changed the source to reflect what the bus pirate tells me it is
Code: [Select]
 {
.name = "24FJ64GB002",
.ID = 0x4207,
.flash = 344*256,
.eeprom = 0,
.family = FAMILY_24FJxxGBxxx,
},
if someone wants to upload this to svn go ahead.

Thanks for all the help! now i gotta figure out what my first PIC is going to be used for lol
Title: Re: Pic24fj64gb002
Post by: tayken on December 22, 2010, 12:31:35 am
Congrats!! Try blinking an LED if this is your first PIC. "Hello World!" of microcontrollers. Also you can get some tutorials from Microchip's web site.

For a project: What do you need in your life? For example, I'm planning to build myself an artificial sunlight alarm clock one of these days. :)
Title: Re: Pic24fj64gb002
Post by: sirus on December 22, 2010, 12:59:24 am
yeah I'm actually not even sure how to setup the config bits or do anything really. I've been trying to follow tutorials online, but it seems like so much work just to get talking to the chip. I have a few projects scheduled though.
nes/snes/gameboy color flash cart (should have most of the parts i need)
Genesis flash cart (because it should be super simple. genesis just had a cap, a resistor, and a memory chip)
Remote car starter with wireless temp and battery voltage measurements. with the ability to cycle the car on if voltage gets too low or it gets too cold.
replace all the brains in the roomba my dog peed on (twice)
and then wall-e here needs some animation http://dl.dropbox.com/u/7706551/IMG_20101213_163336.jpg (http://http://dl.dropbox.com/u/7706551/IMG_20101213_163336.jpg)
Title: Re: Pic24fj64gb002
Post by: ian on December 22, 2010, 08:38:43 am
Nice work, thanks for the code contribution. I'm glad you got it going.
Title: Re: Pic24fj64gb002
Post by: sirus on December 22, 2010, 09:06:27 am
thanks hope it's not my last contribution
Title: Re: Pic24fj64gb002
Post by: sirus on December 22, 2010, 09:48:23 am
could we just use the aux pin? or can v5 and v3.3 be turned on independently on the bus pirate?


Code: [Select]
ENVREG/DISVREG and VCAP/VDDCORE pins 
(PIC24FJ devices only)
(see Section 2.4 “Voltage Regulator Pins
(ENVREG/DISVREG and VCAP/VDDCORE)”)
These pins must also be connected if they are being
2.4 Voltage Regulator Pins
(ENVREG/DISVREG and
VCAP/VDDCORE)
The on-chip voltage regulator enable/disable pin
(ENVREG or DISVREG, depending on the device
family) must always be connected directly to either a
supply voltage or to ground. The particular connection
is determined by whether or not the regulator is to be
used:
• For ENVREG, tie to VDD to enable the regulator,
or to ground to disable the regulator
• For DISVREG, tie to ground to enable the
regulator or to VDD to disable the regulator
Refer to Section 26.2 “On-Chip Voltage Regulator”
for details on connecting and using the on-chip
regulator.
Title: Re: Pic24fj64gb002
Post by: ian on December 22, 2010, 10:00:28 am
Sorry, that was a reply to the wrong thread :)
Title: Re: Pic24fj64gb002
Post by: sirus on December 22, 2010, 10:00:47 am
or "not gate + or gate"?
envreg on the opposite side of the not gate from the dc power source and disvreg on the opposite side of the or gate
Title: Re: Pic24fj64gb002
Post by: ian on December 22, 2010, 10:48:11 am
The supplies are tied together.
Title: Re: Pic24fj64gb002
Post by: sqkybeaver on December 22, 2010, 01:26:37 pm
you could always get a pickit http://shop.ebay.com/?_from=R40&_trksid ... Categories (http://shop.ebay.com/?_from=R40&_trksid=p5197.m570.l1313&_nkw=pickit&_sacat=See-All-Categories)
i only spent 20 on mine
Title: Re: Pic24fj64gb002
Post by: Sjaak on December 22, 2010, 02:08:21 pm
[quote author="sqkybeaver"]
you could always get a pickit http://shop.ebay.com/?_from=R40&_trksid ... Categories (http://shop.ebay.com/?_from=R40&_trksid=p5197.m570.l1313&_nkw=pickit&_sacat=See-All-Categories)
i only spent 20 on mine
[/quote]

That would be cheating. If you would reflash the pickit2/3 with buspirate firmware on the contrary...
Title: Re: Pic24fj64gb002
Post by: sqkybeaver on December 22, 2010, 02:43:36 pm
it would be nice to be able to rescue a bad pickit update
i wonder if a simple bp firmware would work in a pikit2? have only used mine on pics so far.
Title: Re: Pic24fj64gb002
Post by: sirus on December 22, 2010, 06:42:22 pm
[quote author="sqkybeaver"]
you could always get a pickit http://shop.ebay.com/?_from=R40&_trksid ... Categories (http://shop.ebay.com/?_from=R40&_trksid=p5197.m570.l1313&_nkw=pickit&_sacat=See-All-Categories)
i only spent 20 on mine
[/quote]


I think for this chip i would have needed a pickit 3. cheapest i've seen for a genuine one of those was more than $30 + S&H
I'm very cash limited (see poor in the dictionary :P ) so i bought a bus pirate instead since it would be multifunction
Title: Re: Pic24fj64gb002
Post by: sqkybeaver on December 22, 2010, 09:05:07 pm
mine was in a kit form. bare pcb no case. i don't know if it is worth building our own clone, probably could be done a little cheaper.
Title: Re: Pic24fj64gb002
Post by: sirus on December 23, 2010, 02:21:17 am
[quote author="sqkybeaver"]
mine was in a kit form. bare pcb no case. i don't know if it is worth building our own clone, probably could be done a little cheaper.
[/quote]

is there anything a pickit clone can do that a bus pirate cant? or bus pirate + hvp adapter for those chips
Title: Re: Pic24fj64gb002
Post by: sqkybeaver on December 23, 2010, 04:11:31 am
i am unaware if the buss pirate can debug pics, as i use that feature often.
if your only programing sure the bp would be fine.
Title: Re: Pic24fj64gb002
Post by: tayken on December 23, 2010, 05:03:09 am
[quote author="sirus"]
I think for this chip i would have needed a pickit 3. cheapest i've seen for a genuine one of those was more than $30 + S&H
I'm very cash limited (see poor in the dictionary :P ) so i bought a bus pirate instead since it would be multifunction
[/quote]

Pickit2 can program PIC24/dsPIC33 families. Only PIC32 family is not supported as I know.
Title: Re: Pic24fj64gb002
Post by: ian on December 23, 2010, 06:34:03 am
Bus Pirate PIC programming support it just emerging, so I would say the PICkit2 will do one thing the Bus Pirate cannot: program PICs ;)
Title: Re: Pic24fj64gb002
Post by: rsdio on December 23, 2010, 11:55:56 am
... also, the Bus Pirate is slower at this than a dedicated programmer.  If you already have the Bus Pirate, are strapped for cash, and have time to spare, then it's no problem.  But if you're looking at buying something and will be focused on PIC development, then the PICkit is probably a faster, more reliable choice.  It all depends upon what you're doing and how frequently.  I have a whole handful of programmers because they can break, and I never want to be stuck without a working one.  In that respect, the Bus Pirate makes a great backup tool in a pinch (for just about any task, not just programming).
Title: Re: Pic24fj64gb002
Post by: sqkybeaver on December 23, 2010, 09:39:45 pm
maybe we could eventually work our way to simple debug if it will fit in firmware. maybe the pickit3 would be a better choice to look at, i am waiting for microchips firmware to mature for it.
Title: Re: Pic24fj64gb002
Post by: dpropicweb on December 23, 2010, 11:33:29 pm
[quote author="tayken"]
Pickit2 can program PIC24/dsPIC33 families. Only PIC32 family is not supported as I know.
[/quote]

PICkit2 supports programming the PIC32 family - you need to use the standalone PICkit2 software (not MPLAB).
Title: Re: Pic24fj64gb002
Post by: sqkybeaver on December 24, 2010, 12:19:47 am
i did not know it will program some chips it will not debug!
at least it was cheaper than my Silabs debugger.
Title: Re: Pic24fj64gb002
Post by: sirus on December 24, 2010, 05:10:31 am
[quote author="ian"]
Bus Pirate PIC programming support it just emerging, so I would say the PICkit2 will do one thing the Bus Pirate cannot: program PICs ;)
[/quote]


Pffft details details .... ;)

let's get that fixed lol
Title: Re: Pic24fj64gb002
Post by: sirus on December 24, 2010, 10:56:18 am
Patch created with
Code: [Select]
svn diff --diff-cmd diff -x "-i -b" > 24FJ64GB002
should be able to apply with
Code: [Select]
patch -p0 < 24FJ64GB002

not sure though never actually made one of these before. only applied them

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01672167976session_write_close ( )...(null):0
20.01712299568ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01712300344Database_MySQL->query( ).../DatabaseHandler.php:119
40.06242439080Database_MySQL->error( ).../Db-mysql.class.php:273