PDA

View Full Version : Power-down at the bad time = WRITE



bogdan
- 1st March 2009, 02:12
p16F913

I will like to know what is gonna happen if i power down the microcontroller when the WRITE instructions are in use

To be more accurate let say i will like to write a word variable (16 bits) to eeprom (14 bits).... so i have to use:

HIGH_BYTE=VAR/256
LOW_BYTE=VAR-HI_BYTE

WRITE X, HI_BYTE
...power-down mcu occur HERE
WRITE Y,LOW_BYTE


Thank you

mackrackit
- 1st March 2009, 07:39
You will have bad data at that EEPROM address.

Charles Linquis
- 1st March 2009, 17:22
If you have data that absolutely cannot be corrupted, then write the data twice in two different blocks. Write a checksum as the last byte of each block.
On power up, read the blocks and recalculate the checksums. Use the first one that matches.

nomad
- 1st March 2009, 17:48
would it be easier to use

WRITE X,VAR.BYTE1
WRITE Y,VAR.BYTE0

(I know, not the question lol)

bogdan
- 1st March 2009, 19:20
what checksum algorithm did you recomend ?



...day by day i have to go deeper and deeper...and just for one countdown timer :D ... i love that

Charles Linquis
- 1st March 2009, 20:55
For something simple, I generally start with something like $AA or $55 and add every byte to that. Fast and (relatively) foolproof.

bogdan
- 1st March 2009, 22:38
thank you for your help guys