Problem of EEPROM Write and read

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem of EEPROM Write and read

1,585件の閲覧回数
JalenZ
Contributor I

Hi all:

     The MCU is S08EL16, development tool is CW6.3, use "Full chip simulation"

     Please see the attached project file, the questions:

             Q1: In the main.c file, I want to read a data from the eeprom, when I read data from the address 0x1700, the return value is 0x33 but not 0x22, why this happend?

             Q2: I also want to wrtie a data(0x55) into the address 0x1700 use the function " write_eeprom_byte", but it's not work, why?

 

    Thanks!

ラベル(1)
0 件の賞賛
返信
2 返答(返信)

1,129件の閲覧回数
bigmac
Specialist III

Hello,

 

Usually FCS does not simulate the programming of flash memory.  It would therefore not surprise me if the related EEPROM programming was also not simulated.

 

I think that you will need to prove this part of your code using the real hardware.

 

Regards,

Mac

 

0 件の賞賛
返信

1,129件の閲覧回数
kef
Specialist I

#define EEPROM_ACCESS(x) *(word *)(x)

Did you use this macro to read from 0x1700? Assigning EEPROM_ACCESS(0x1700)  to char variable will give 0x33.

 

 

 

write_eeprom_byte is full of bugs:

 

    FSTAT_FACCERR = 1;   Is wrong. This will also write one to FCBEF bit and probably will set again some error bit.

Use FSTAT = FSTAT_FACCERR_MASK;

 

  *(word*)(addr) = data;
S08 eeprom is byte programmable, not word programmable.

In your case EEPROM at 0x1700 is not erased. You should erase it before programming.

  FSTAT_FCBEF = 1;

    FSTAT_FACCERR = 1;

    FSTAT_FPVIOL = 1;

    FSTAT_FACCERR = 1;

  EEPROM_ACCESS(addr) = data;   // Write the data
EEPROM_ACCESS should write byte (*(char*)x).

  FSTAT = 0x80;                 // Clear command buffer empty flag

Don't use "magic constants". FSTAT = FSTAT_FCBEF_MASK; is somewhat self documenting.

0 件の賞賛
返信