CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Programming PIC without erasing EEPROM

 
Post new topic   Reply to topic    CCS Forum Index -> CCS ICD / Mach X / Load-n-Go
View previous topic :: View next topic  
Author Message
MarcosAmbrose



Joined: 25 Sep 2006
Posts: 38
Location: Adelaide, Australia

View user's profile Send private message

Programming PIC without erasing EEPROM
PostPosted: Mon Apr 23, 2007 8:06 pm     Reply with quote

Everytime re-compile and upload new code to my target board, the ICD-U40 erases the EEPROM.

"PCM programmer" posted a link in previous post which had the same problem, but the link doesn't work anymore. "PCM programmer", can you or anyone else recall what the solution was? -Cheers
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 24, 2007 6:43 pm     Reply with quote

Here is the information from that link:
Quote:

If anyone else wants to know how to preserve the Data EEPROM on the
target chip, you have to click on "Advanced" in the ICD Control program
(invoked by clicking the little hammer and wrench icon in the Debug
Configure tab), then select "Erase when needed" under the Erase Modes
section. As long as the program file being downloaded doesn't contain
any Data EEPROM data, the Data EEPROM section of flash memory will
be preserved.
Dimmu



Joined: 01 Jul 2007
Posts: 37

View user's profile Send private message

PostPosted: Tue Jul 17, 2007 1:46 pm     Reply with quote

Is it normal that I do not see the "Erase when needed" option but only the "bulk erase" and the "no erase" options in the Erase modes section ?

I found that the Erase and Burn section allows to prevent the EEPROM from being programmed, but the tools often resets my settings. Is it a special way to force this setting -but still the best option would be to used the famous erase when needed...- ?

Dimmu
nilsener



Joined: 06 Dec 2005
Posts: 59

View user's profile Send private message

PostPosted: Mon Dec 07, 2009 11:40 am     Reply with quote

Hello Dimmu,

Sorry for reactivating this old thread. I have the same problem but with Microchips MPLAB ICD2. It seems to be impossible to reprogram the PIC with new software without erasing the EEPROM that is Code Protected in this case. My data in EEPROM must not be erased as it contains calibration data.

Have you solved your problem with the ICD-U40 to program (not to debug) the PIC while don't erasing the EEPROM? Then I will buy an ICD-U40.

Best Regards
nilsener
Dimmu___
Guest







PostPosted: Mon Dec 07, 2009 1:09 pm     Reply with quote

Nope,

Never found a good way to do this.

On the other hand, I didn't touch a PIC for about 1 year now, so maybe the softwares have been updated since.

Best regards
Dimmu
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 08, 2010 11:06 am     Reply with quote

It's very easy to program a PIC chip without touching the EEPROM if you use a pickit 2 or 3 with their software. So that's a possibility if you have no other way to do it. Pickit2 is pretty cheap.
JH1987



Joined: 22 Jan 2011
Posts: 11

View user's profile Send private message

Can't Preserve Data EEPROM with PickIt 2
PostPosted: Sat Jan 22, 2011 12:58 pm     Reply with quote

collink wrote:
It's very easy to program a PIC chip without touching the EEPROM if you use a pickit 2 or 3 with their software. So that's a possibility if you have no other way to do it. Pickit2 is pretty cheap.


I'm having trouble programming a PIC while preserving Data EEPROM with the Pickit 2. What I'm trying to do is recover EEPROM data from a unit that had a failure in the field. I don't have the option of just reading back the Data EEPROM without programming because I have the CPD fuse set, which read-protects the Data EEPROM. So I have to download a program that prints the contents of EEPROM out on an rs232 pin.

I'm using the Pickit 2 Programmer app:
App Version 2.61.00
Device File Version 1.62.03
OS FW Version 2.32.00

and a PIC18F4685 which has 256 bytes of Data EEPROM.

I unchecked the Data EEPROM box in the app, which says 'preserving device EEPROM data on write'. However, I have to erase before I can write. When I erase, the Data EEPROM is not preserved. So there seems to be no way to preserve it. I also tried unchecking the mysterious 'Clear Memory Buffers on Erase', which seems to be the only setting which may affect the EEPROM. This setting is not discussed in the Pickit documents. Any idea what it means?

Anyway, I seem to be at a dead end and I really need that data. I'd really appreciate any help you guys could offer.
JH1987



Joined: 22 Jan 2011
Posts: 11

View user's profile Send private message

Doesn't Seem Possible with CPD
PostPosted: Sat Jan 22, 2011 1:41 pm     Reply with quote

collink wrote:
It's very easy to program a PIC chip without touching the EEPROM if you use a pickit 2 or 3 with their software. So that's a possibility if you have no other way to do it. Pickit2 is pretty cheap.


Based on what I read on Microchip forums, I think what you're talking about involves the Pickit reading the data EEPROM, erasing the whole chip, programming the chip, then writing the data EEPROM with the old values.

If you have the CPD (Data EEPROM code-protected) fuse set, then it can't read the EEPROM. That's why I can't just read the EEPROM in the GUI and get the data.

Is there any way to make this thing only erase/write program memory without touching data EEPROM? Some way to give it an address range? The GUI is really limited. I guess I could check out the cmd line option. I'll keep searching.
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sat Jan 22, 2011 9:35 pm     Reply with quote

What you want to do is theoretically possible, but not with your current hardware (programmer) and software.

Microchip have a relevant programming specification document:

http://ww1.microchip.com/downloads/en/DeviceDoc/39622L.pdf

See section 3 on page 14. There are specific commands to selectively erase portions of code memory, allowing it to be reprogrammed. However, I don't know of any package to let you do this, so you'll either have to develop one yourself (and corresponding hardware), or find some open source PIC programmer software that you could modify.
_________________
Andrew
JH1987



Joined: 22 Jan 2011
Posts: 11

View user's profile Send private message

Thanks for getting back to me
PostPosted: Sun Jan 23, 2011 11:36 am     Reply with quote

andrewg wrote:
What you want to do is theoretically possible, but not with your current hardware (programmer) and software.

Microchip have a relevant programming specification document:

http://ww1.microchip.com/downloads/en/DeviceDoc/39622L.pdf

See section 3 on page 14. There are specific commands to selectively erase portions of code memory, allowing it to be reprogrammed. However, I don't know of any package to let you do this, so you'll either have to develop one yourself (and corresponding hardware), or find some open source PIC programmer software that you could modify.


You're right, it's not possible with the Pickit 2.

The programming doc was helpful. An "Erase Configuration Bits" command would solve the problem. It would set the CPD back to 1, which leaves the Data EEPROM unprotected. Then I could just read out the data EEPROM with the Pickit GUI.

At this point its simpler just to program out-going units with the CPD set to 1, and wait for the failure to occur again. It's a rare problem that affects a very small % of units, but it would be nice to have the data now instead of in a month.

If somebody is in the same situation but they absolutely need the info in Data EEPROM, they could build a Pickit board themselves. Microchip provides the schematics and the code (for the Microchip compiler), so you could spin your own board and modify the Pickit firmware.

Thanks for your help.
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

Re: Thanks for getting back to me
PostPosted: Sun Jan 23, 2011 10:01 pm     Reply with quote

JH1987 wrote:
An "Erase Configuration Bits" command would solve the problem.
FYI, you've missing the note on the page that says a bulk erase is the only way to do that.

There's also a sentence that says if the data EEPROM is protected, you must ask for it to be erased.

On thinking about it, Microchip takes it's data protection facilities fairly seriously, and I'd be surprised if you could get access to protected data even indirectly.

Maybe you could change the firmware to support a debug dump of the data? For example, I use a 6-pin ICSP header and for one project I have it set up so that if I short the middle two pins (GND and B7) with a screwdriver the board goes into a "factory setup" mode. Adding a debug dump, even if it's a bit-bang serial port on B5/6/7 would be quite possible, unless you're already using those pins, of course.
_________________
Andrew
JH1987



Joined: 22 Jan 2011
Posts: 11

View user's profile Send private message

Bulk Erase
PostPosted: Mon Jan 24, 2011 10:15 am     Reply with quote

Hey Andrew,

I actually did see the sentence "A Bulk Erase is the only way to reprogram
code-protect bits from an ON state to an
OFF state."

But since the bulk erase operation is configurable, I thought you could set the Bulk Erase Control registers to something like Erase Configuration Bits (0082h) and then execute the bulk erase. I wonder if that would turn off code protection. Like you say, Microchip takes code protect seriously, so maybe the IC has another safeguard. And you're right, they do say you have to erase data EEPROM when protected. But you'd think if you could do that bulk erase and clear the config bit, then you could get to the EEPROM. It might make an interesting experiment...

As for the factory debug feature, I could definitely do that. I was trying to replace the code in the PIC with code that did almost exactly that. For me its easier just to turn of CPD, since that EEPROM data really doesn't need to be protected. For somebody that needs protection, your option is better.

Thanks for your reply.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> CCS ICD / Mach X / Load-n-Go All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group