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!
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
#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.