cancel
Showing results for 
Search instead for 
Did you mean: 

ST7lite29 loosing EEPROM data

bleumers_j
Associate II
Posted on July 03, 2003 at 10:24

ST7lite29 loosing EEPROM data

9 REPLIES 9
bleumers_j
Associate II
Posted on June 04, 2003 at 13:24

Hello,

another problem i have:

After writing data into the EEPROM-space of the st7lite29, the chip sometimes looses parts of this data.

When i repower the circuit a few times, after aprox. 5 times a part of 3 bytes are set FF. Thes 3 bytes are written quite often in the software.

Is it possible that the data disapears when the power is interrupted in while the ST7 is writing its EEPROM?

Thanks,

Johan
bleumers_j
Associate II
Posted on June 05, 2003 at 05:46

Hello again,

Maybe it is a better sollution to do not use the EEPROM at all, and only use the RAM. Because writing to the EEPROM every millisecond isn't a good idea at all!

I'm planning to hold the data in the RAM after the power is disconnected by putting the ST7 into haltmode and use a battery for its supply. Ony input pin is used to sense the supply voltage and put the ST7 into haltmode after the voltage drops. A RC-network resets the ST7 after power is back and puts it into RUN-mode again.

Is this a good idea???

[ This message was edited by: joble on 05-06-2003 09:26 ]
stephanie
Associate II
Posted on June 05, 2003 at 07:54

When you say EEPROM, do you speak about the Flash (EEPROM technology) ot about the data EEPROM??

Anyway in both case, if data are written in the correct way, a switch-off of the power supply has no effect on the data retention for sure!

Are you sure not to overwrite these 3 bytes (always the same ones I suppose?) in your software?
bleumers_j
Associate II
Posted on June 05, 2003 at 10:50

Hi,

I mean the data EEPROM.

The way i'm working is totaly wrong, but i do not know what is the good way...

What i need is:

* 3 variables can be changed at any time (by 6 pushbuttons + and -)

* The data must remain in memory during an interruption of the supply.

I solved it by writing it into EEPROM every time the pushbuttons are polled. (a few times per millisecond) This is no good idea, and data seem to be lost (turned into 0xFF) sometimes.

Maybe it is better to write the EEPROM only when the voltage drops. (in an AVD interrupt). Is there enough time to do this?

Has anyone a better idea???
bleumers_j
Associate II
Posted on June 05, 2003 at 13:06

Hello again,

I tried the last sollution(writing the data while supply voltage drops), and it works... but:

I have to place a 2200µF elco over the supply pins to ensure the voltage drops slow enough. When i don't do this nothing is written into EEPROM. With smaller elco's the data isn't allways correct.

Is it normal i should use such a big capacitor???

[ This message was edited by: joble on 05-06-2003 16:37 ]
stephanie
Associate II
Posted on June 11, 2003 at 06:11

The time you will have to perform actions in your AVD interrupt routine depends on the Vdd falling, but to write some bytes in EEPROM data, it should be enough! No need to add such big capacitors....Try to extract the software corresponding to this part and post it in this forum, people will be able to have a look on it and to help you.

bleumers_j
Associate II
Posted on June 11, 2003 at 07:31

Here is a part of my code:

Almost everything is saved in the interruptmodule ''low-voltage''. Only in ''void statisch(void)'' data is written into EEPROM.

include ''Io7FLite0.h'' // ST7Flite0 memory and registers mapping

include ''lib_bits.h'' // Predifined libraries working at bit level

include ''bitdef.h'' // This file defines the names of the bits

include

int kleur_stat[3];

int kleur_dyn[3];

int kleur = 0;

int intensiteit_dyn2 = 0;

int snelheid_dyn1 = 0;

int snelheid_dyn2 = 0;

int snelheid_dyn3 = 0;

int snelheid_dyn4 = 0;

int snelheid_dyn5 = 0;

int snelheid_dyn6 = 0;

int snelheid_dyn7 = 0;

int snelheid_dyn8 = 0;

//int achtergrond_dyn3 = 0;

int laatstePADR7=0,mode=0,laatstemode=0,laatstePBDR5=0,dynmode=0;

int teller2=0, teller3=0,teller4=0;

int nieuwrood[9] , nieuwgroen[9], nieuwblauw[9], aantalkleuren = 0;

void statisch(void)

{

unsigned char *matrix=(unsigned char *)0x1021; // EEPROM

unsigned char *aantalkleuren_ER=(unsigned char *)0x1020;

kleur_stat[0] = leesknop(1,kleur_stat[0]);

schrijfPWM(1,kleur_stat[0]);

kleur_stat[1] = leesknop(2,kleur_stat[1]);

schrijfPWM(2,kleur_stat[1]);

kleur_stat[2] = leesknop(3,kleur_stat[2]);

schrijfPWM(3,kleur_stat[2]);

if (!ValBit(PBDR,5)) // Druktoets niet ingedrukt

laatstePBDR5=0;

if (ValBit(PBDR,5)) // Druktoets wel ingedrukt

{

if (laatstePBDR5==0 && kleur < 9) //stijgende flank geweest?

{

nieuwrood[kleur] = kleur_stat[0];

nieuwgroen[kleur] = kleur_stat[1];

nieuwblauw[kleur] = kleur_stat[2];

EECSR=0x02; //Write mode van EEPROM

matrix[kleur*3+0]= kleur_stat[0];

matrix[kleur*3+1]= kleur_stat[1];

matrix[kleur*3+2]= kleur_stat[2];

aantalkleuren_ER[0] = kleur+1;

EECSR=0x03; // start programmeren

while (EECSR&0x01){}; // wacht tot programmeren klaar is.

kleur++;

aantalkleuren = kleur;

}

laatstePBDR5=1;

}

}

void main(void)

{

//DECLARATIES

//-----------

unsigned char *EEPROM=(unsigned char *)0x1002; // EEPROM

//INITIALISATIE

//-------------

PADDR=0x7F; // Define PA0

A4 as output push pull

PAOR=0x03; //

PBDDR=0x00;

PBOR=0x00;

_asm(''rim'');

ATCSR=0x10;

ATRH=0x00; //Frequentie

ATRL=0x00; //Frequentie

PWMCR=0x55; //Alle PWM's aan

TRANCR=0x01;//

SetBit (SICSR,0);

ClrBit (SICSR,1);

clearPWM();

// Alle gebackupte gegevens uit EEPROM

EECSR=0x00;

kleur_stat[0] = EEPROM[0];

kleur_stat[1] = EEPROM[1];

kleur_stat[2] = EEPROM[2];

mode = EEPROM[3];

dynmode = EEPROM[4];

snelheid_dyn1 = EEPROM[5];

snelheid_dyn2 = EEPROM[6];

snelheid_dyn3 = EEPROM[7];

snelheid_dyn4 = EEPROM[8];

snelheid_dyn5 = EEPROM[9];

snelheid_dyn6 = EEPROM[10];

intensiteit_dyn2 = EEPROM[11];

snelheid_dyn7 = EEPROM[13];

snelheid_dyn8 = EEPROM[14];

//wrong values in EEPROM??? -> correct them

if (mode > 1)

mode = 0;

if (dynmode >

dynmode = 0;

- - -

- - -

- - -

- - -

- - -

- - -

}

}//End void main(void)

@interrupt void lowvoltage(void)

// voltage drop… save data to EEPROM

{

unsigned char *EEPROM=(unsigned char *)0x1002; // EEPROM

EECSR=0x02; //Write mode EEPROM

EEPROM[0] = kleur_stat[0];

EEPROM[1] = kleur_stat[1];

EEPROM[2] = kleur_stat[2];

EEPROM[3] = mode;

EEPROM[4] = dynmode;

EEPROM[5] = snelheid_dyn1;

EEPROM[6] = snelheid_dyn2;

EEPROM[7] = snelheid_dyn3;

EEPROM[8] = snelheid_dyn4;

EEPROM[9] = snelheid_dyn5;

EEPROM[10] = snelheid_dyn6;

EEPROM[11] = intensiteit_dyn2;

EEPROM[13] = snelheid_dyn7;

EEPROM[14] = snelheid_dyn8;

EECSR=0x03; // start programming

while (EECSR&0x01){}; // wait until programming is done.

}

frederic2399
Associate
Posted on June 11, 2003 at 13:51

Hello,

I am using Lite29 and I do not have any problem with EEPROM but I remind you that datasheet specificies a typical programming time of 5ms so you will not be able to write data several time per ms. I guess you are corrupting the operation by doing this.

If you follow the flowchart (fig. 7, p16/130) in the datasheet, it will work.
sernoux
Associate
Posted on July 03, 2003 at 10:24

Hi Johan,

Why do you need to save the data many times per millisecond?

Ca you explain how works the push button, and what is the result you expect out of it?