2003-06-01 10:58 PM
2003-05-20 12:32 AM
I have a problem with the Eeprom in st72334n4, when I program the following it runs fine:
EECSR = EECSR | 0x02; a[0]= 0.50863406; a[1]= 0.50863406; a[2]= 0.50863406; while (EECSR & 0x02) {} But when I add this the µP goes into a coma: EECSR = EECSR | 0x02; b[0]= 3333; b[1]= 3333; b[2]= 3333; EECSR = EECSR | 0x01; while (EECSR & 0x02) {} I write it after the first programming cycle, it doesn't matter if I make a delay between them. In the manual for the µP stands the following: ''To avoid wrong programming, the user must take care that all the bytes written between two programming sequences have the same high address: only the four Least Significant Bits of the address can change.'' I know that my least 8 significant bits are changing, but when can I program the last cycle, that is my question? Because I am blank because I have tried under EnableInterrupts and above EnableInterrupts. I hope for someone who can help me with this odd question... Thanks Thor2003-05-20 10:25 PM
Take care that EECSR register allows only to write in the EEPROM DATA of the MCU. CFlash devices are different from the XFlash or HDFlash devices where the FCSR register allows to write the Flash.
Then, you can write up to 16 bytes in parallel but their addresses have to be consecutive! (the 12MSB of the addresses have to be the same as precised in the datasheet).2003-05-21 12:30 AM
I am sorry because I have made an error in my text, I wrote 8 least significant bits were changing, I ment 4 bits.
But after a series of tests I have come to this conclusion that my problem only accours when I try to program the Eeprom after it is finished with the first programming cycle. What shall I do between the two programming cylces before it will work. I do make sure that the EECSR is cleared. Thor2003-05-21 02:51 AM
Post your software on the forum! There is certainly something wrong inside cause I've already used it and it worked.
2003-05-21 09:49 PM
2003-05-21 10:20 PM
Here it is:
#pragma DATA_SEG A_SPACE float a[3]; #pragma DATA_SEG B_SPACE signed int b[3]; A-B_SPACE is in the EEPROM area. The adresses for the variables are listed in the map-file as following: SEGMENT ''A_SPACE'' a C00 C ( 16) A_SPACE SEGMENT ''B_SPACE'' b C10 6 ( 8) B_SPACE the source code is this: EECSR = EECSR | 0x02; a[0]= 0.50863406; a[1]= 0.50863406; a[2]= 0.50863406; EECSR = EECSR | 0x01; while (EECSR & 0x02) {} EECSR = EECSR | 0x02; b[0]= 3333; b[1]= 3333; b[2]= 3333; EECSR = EECSR | 0x01; while (EECSR & 0x02) {} I hope this helps????? [ This message was edited by: Thor on 22-05-2003 10:50 ][ This message was edited by: Thor on 22-05-2003 10:51 ]2003-05-27 09:49 PM
I found two points in your software that can be checked:
EECSR = EECSR | 0x02; ===> here add EECSR &= 0xFE; /* to make sure PGM is clear*/ a[0]= 0.50863406; a[1]= 0.50863406; a[2]= 0.50863406; EECSR = EECSR | 0x01; while (EECSR & 0x02) ==> this condition should be like while(EECSR & 0x03){} /* Wait for PGM bit to be cleared*/ EECSR = EECSR | 0x02; ===> here add EECSR &= 0xFE; /* to make sure PGM is clear*/ b[0]= 3333; b[1]= 3333; b[2]= 3333; EECSR = EECSR | 0x01; while (EECSR & 0x02) ==> this condition should be like while(EECSR & 0x03){} /* Wait for PGM bit to be cleared*/2003-06-01 10:58 PM
Thnaks to everyone!
I works now and i have located the problem, it was my adresses there ****** it up! Regards Thor