Writing to EEPROM

Started by wwsyip June 10, 2004
Hi there,

I'm trying to find a way to write a value and be able to retrieve
after resetting the HC12. I have been told by the technological arts
people that this can be done using EEPROM.

Does anyone know how to do it or have any source code? Thanks!



Hello,

Oliver Thamm sent me this function when i tried to write on the EEPROM and it works good.

INT8 wrSectEETS(UINT16 *dest, UINT16 *src) {

// check addr: must be aligned 32 bit
if((UINT16)dest & 0x0003) return -1;
// check if ECLKDIV was written
if((ECLKDIV & BM_EDIVLD) == 0) return -2;
// make sure error flags are reset
ESTAT = BM_PVIOL | BM_ACCERR;
// check if command buffer is ready
if((ESTAT & BM_CBEIF) == 0) return -3;
// check if sector is erased
if((*dest != 0xffff) || (*(dest+1) != 0xffff)) {
// no, go erase sector
*dest = *src;
ECMD = EETS_CMD_SERASE;
ESTAT = BM_CBEIF;
if(ESTAT & (BM_PVIOL | BM_ACCERR)) return -4;
while((ESTAT & BM_CBEIF) == 0) ;
}
// program 1st word
*dest = *src;
ECMD = EETS_CMD_PROGRAM;
ESTAT = BM_CBEIF;
if(ESTAT & (BM_PVIOL | BM_ACCERR)) return -5;
while((ESTAT & BM_CBEIF) == 0) ;
// program 2nd word
*(dest+1) = *(src+1);
ECMD = EETS_CMD_PROGRAM;
ESTAT = BM_CBEIF;
if(ESTAT & (BM_PVIOL | BM_ACCERR)) return -6;
while((ESTAT & BM_CCIF) == 0) ;
return 0;
}

Regards
----- Original Message -----
From: wwsyip
To:
Sent: Thursday, June 10, 2004 8:44 PM
Subject: [68HC12] Writing to EEPROM Hi there,

I'm trying to find a way to write a value and be able to retrieve
after resetting the HC12. I have been told by the technological arts
people that this can be done using EEPROM.

Does anyone know how to do it or have any source code? Thanks!
--------------------To learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
o learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
------
Yahoo! Groups Links

a.. To



In a message dated 6/10/04 2:53:16 PM Eastern Daylight Time,
writes:

Does anyone know how to do it or have any source code? Thanks!

===============================================
The imagecraft c compiler has read and write routines for the eeprom.



i see.

How would I be able to access these?

--- In , BobGardner@a... wrote:
>
> In a message dated 6/10/04 2:53:16 PM Eastern Daylight Time,
> wwsyip@y... writes:
>
> Does anyone know how to do it or have any source code? Thanks! >
>
> ===============================================
> The imagecraft c compiler has read and write routines for the
eeprom.