cancel
Showing results for 
Search instead for 
Did you mean: 

Eeprom programming for st72334n4

thor
Associate II
Posted on June 02, 2003 at 07:58

Eeprom programming for st72334n4

8 REPLIES 8
thor
Associate II
Posted on May 20, 2003 at 09:32

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

Thor

stephanie
Associate II
Posted on May 21, 2003 at 07:25

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).

thor
Associate II
Posted on May 21, 2003 at 09:30

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.

Thor

stephanie23
Associate II
Posted on May 21, 2003 at 11:51

Post your software on the forum! There is certainly something wrong inside cause I've already used it and it worked.

thor
Associate II
Posted on May 22, 2003 at 06:49

[ This message was edited by: Thor on 22-05-2003 10:46 ]
thor
Associate II
Posted on May 22, 2003 at 07:20

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 ]
itsmejatinus
Associate II
Posted on May 28, 2003 at 06:49

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*/

thor
Associate II
Posted on June 02, 2003 at 07:58

Thnaks to everyone!

I works now and i have located the problem,

it was my adresses there ****** it up!

Regards

Thor