cancel
Showing results for 
Search instead for 
Did you mean: 

ST72334 Data EEPROM programming

celine2
Associate II
Posted on January 27, 2006 at 05:35

ST72334 Data EEPROM programming

12 REPLIES 12
celine2
Associate II
Posted on January 11, 2006 at 11:05

Hello,

I need to use the internal EEPROM of the st72334. I read the datasheet, but I can't figure out how to use it. Could someone please explain me step by step (I'm a beginner) how I'm supposed to write and read data from the EEPROM?

All I understood is that I need to change the LAT bit if I need the Read or Write mode. But I do not know how to change the memory adresses of the data I want to send to the EEPROM.

And I also do not know where to put the data I want to send to the EEPROM.

Thanks a lot.

Philippe

franco
Associate II
Posted on January 12, 2006 at 07:27

Here it's a simple code for writing in data eeprom;

DataEEprom

ld a,#%00000010

ld EEPCR,a

ld a,#77

ld {$0C00},a

ld a,#%00000011

ld EEPCR,a

btjt EEPCR,#1,*

ret

with this routine I write ''77'' into ''0C00'' memory location,then data eeprom...

With this code,I read what i wrote into ''0C00'' memory location;

ld a,#%00000000

ld EEPCR,a

ld a,{$0C00}

I hope this can help you

;)

celine2
Associate II
Posted on January 12, 2006 at 20:21

Thanks a lot. I will try that code this week end. I'll tell you if it worked. Thanks again. :)

Philippe

celine2
Associate II
Posted on January 19, 2006 at 11:29

Hello again,

The code you gave me is great, but I'm working in C with Cosmic Compiler.

I've searched on the net and I know how to write in an EEPROM, using the LAT bit and @eeprom.

But I need to write a table of datas in the EEPROM, and I don't know how to change the address where I'm writing, automatically : without having to write myself the next address every time.

Hoping someone can help...

Thank you.

Philippe

[ This message was edited by: Philippe13 on 19-01-2006 16:01 ]

wolfgang2399
Associate II
Posted on January 20, 2006 at 06:12

Hi Philippe,

just for your study I'll append two routines, I use to write to the EEProm.

Hope it helps and there are sufficient comments to discover how the routines work.

Regards

WoRo

________________

Attachments :

EEP_example.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I08c&d=%2Fa%2F0X0000000bUO%2F.CYdOrgYEcpG.gcZbx5UMs0pdPOlxrK7xzXX2a_B1E4&asPdf=false
luca239955_st
Associate III
Posted on January 23, 2006 at 11:54

Quote:

I'm working in C with Cosmic Compiler...

I don't know how to change the address where I'm writing, automatically ...

I'm not sure I understand your problem, but just declare all the variables you want as @eeprom (including an array of them, if you want) and the compiler will handle the whole thing automatically; every variable will be given an address and the eeprom write library routine will be called each time one of these varaibles is given a new value...

Now, if what you want to do is write a whole table at once, there might be a more efficent way to do it, I'd have to check.

Hope it helps.

Luca (Cosmic)

celine2
Associate II
Posted on January 24, 2006 at 09:44

Luca,

I fear I could ''burn'' my ST7, if I do something wrong... :o

If I do :

@eeprom unsigned int a;

in the main.c, and then :

+seg .eeprom -b0x0C00;

in the .lkf, everything is OK. (am I doing it right?)

But if I do :

@eeprom unsigned short tab[4];

the compiler shows this error message :

#error cast7 \s28s.cx2:1053 value too large

so I don't really know how to declare a table in the EEPROM.

Thank you.

Philippe

celine2
Associate II
Posted on January 24, 2006 at 09:50

WoRo,

Thank you for your answer, I think I understand your code : destination is the pointer pointing in the EEPROM. However I do not know how to define destination :

if I do : char* destination;

destination = 0x0C00;

the compiler shows this message :

#error cpst7 main.c:26(0+11) redeclared external destination

so I don't know what to do... :-?

Thank you.

Philippe

wolfgang2399
Associate II
Posted on January 25, 2006 at 07:13

Hi Philippe,

to write one byte with the given procedures you simply enter the value and the target address (pointer) to the call

EEP_wChar(c_value, pC_EEP_target);

To write a number of bytes you have to enter the address (pointer) of the source, the address (pointer) of the target and the number (value) to the call

EEP_wBlock(pC_source, pC_EEP_target, n);

For better understanding I'll give you an example:

...

char* pC_EEPROM; /* pointer to the destination */

char my_table[20]; /* table of values */

....

pC_EEPROM = (char*)0x0C07;

EEP_wChar(my_table[7], pC_EEPROM); /* writes the value of my_table[7] to 0x0C07 */

/* -- or -- */

EEP_wChar(my_table[7], (char*)0x0c07);

...

pC_EEPROM = (char*)0x0c00

EEP_wBlock(&my_table[0], pC_EEPROM, 6); /* writes the values from my_table[0] to my_table[5] to the EEProm */

...

Regards

WoRo