cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM invalid values

biernacki
Associate
Posted on June 24, 2015 at 09:04

Hello, I'm pretty new in STM8 programming. I'm making small project on STM8S103F3P6 microcontroller and I need to save some (27 bytes) values in EEPROM memory and reload them at every power up. I saw an example from ST stdLib and tried to change it for my project. And here is my problem. When I try to save more than 1 byte with function FLASH_ProgramByte(), for exaple:

(...)

FLASH_ProgramByte(0x4000, 0x12);

FLASH_ProgramByte(0x4001, 0x34);

FLASH_ProgramByte(0x4002, 0x56);

(...)

when I view EEPROM content in debugging session, some variables are saved correctly, but some are 0. Also, when I try to reload these values on application start even if EEPROM byte at specific address is set, function FLASH_ReadByte(0x400x); often returns 0, only sometimes returns correct value. MCU is running at 16MHz from HSI. Do I make any mistake? Of course memory is unlocked.

#stm8s103-eeprom-flash
2 REPLIES 2
Philipp Krause
Senior II
Posted on June 24, 2015 at 17:28

16 Mhz should still work without wait states, but it is at the limit. Have you tried configuring your STM8 for 1 wait state in EEPROM access (as required for operation above 16 Mhz)? If yes, did it help?

Philipp

biernacki
Associate
Posted on June 26, 2015 at 08:01

OK, I forgot about EOP bit and now writing to EEPROM works fine. In memory view window during debugging session every EEPROM byte is correct. But reading is still invalid. I'm trying to read values (27 bytes) from memory and I always get some zeros, some values are on invalid address, every byte is wrong. My question is do I need to check another bit when reading EEPROM as EOP when I'm writing and pause execution to get proper values? Why code like below does not work?

val1=FLASH_ReadByte(0x4000);

val2=FLASH_ReadByte(0x4001);

val3=FLASH_ReadByte(0x4002);.......

Thanks for help!