View previous topic :: View next topic |
Author |
Message |
pat
Joined: 07 Sep 2003 Posts: 40 Location: Adelaide, Australia
|
Spurious EEPROM writes |
Posted: Thu Jul 22, 2004 5:46 am |
|
|
Hi
I seem to be getting EEPROM values changing for no valid reason on a 16F876 running at 4MHz. Using PCM v3.168. It seems that the first few locations (ie 0x2100 to about 0x2109) are being changed while the program runs.
This is where I store some calibration values, which the PIC calculates and writes at production. Is it possible to set and clear the EEPROM protect "CPD" fuse programatically? That way, when put in cal mode, I can enable EEPROM writes, store the cal values, and then disable EEPROM writes again.
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 6:01 am |
|
|
Sounds like maybe your code it writing those values. One of the guys here had a similar problem. He was monitoring an input pin on startup to put the device into calibration mode. The device would sometimes go into calibration mode on power up due to the supply settling. A small delay at startup prevented this. |
|
|
pat
Joined: 07 Sep 2003 Posts: 40 Location: Adelaide, Australia
|
|
Posted: Thu Jul 22, 2004 6:09 am |
|
|
Mark, yes I thought this as well. During maufacture, my PIC program is put into cal mode by a serial command from a PC. In operation, the device runs on a truck, which is electrically noisy, and I thought it may have been getting inadvertenly put into cal mode. I've now made the cal command a 3 character binary string, but it still seems to be happening!
I'm still unsure if the EEPROM is being corrupted, or its going into cal mode somehow.
I'd still like to know if the PIC can set/clear its own fuse values please, in particular, the "CPD" fuse at 0x2007 bit-8.
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 22, 2004 6:39 am |
|
|
The configuration registers can only be written to during programming per the datasheet. There are various safe guards to prevent spurious writes. However, there is not protection to keep your code from "glitching" and going into your write routine. You could setup some sort of counter in a location and keep track of how many times it goes into calibration mode or change the location of the calibration data and see if the problem follows. |
|
|
pat
Joined: 07 Sep 2003 Posts: 40 Location: Adelaide, Australia
|
|
Posted: Thu Jul 22, 2004 7:40 am |
|
|
Excellent ideas re my code glitching, I will implement them. And thanks for the config registers info. |
|
|
|