2014-11-18 01:02 AM
I am using the STM32l Discovery board (http://uk.farnell.com/stmicroelectronics/stm32l152c-disco/stm32l-discovery-eval-board/dp/2317987). The ucontroller on the board (STM32L152RB) features 4kB of EEPROM at the address 0x08080000 that can be used for non-volatile data storage.
I was trying to read/write/erase such memory using the pheripheral library stm32l1xx_flash.cMy questions are:1) In the header file stm32l1xx_flash.h all the supported functions are listed. There are functions to unlock/lock the memory, write byte/word, erase byte/word. However there are no functions to read a byte/word. What is the code to read a byte/word at a particular address in the range 0x08080000 - 0x08080FFF?2) Before making a write operation on a byte/word, is it necessary to erase that byte/word before?Thanks.2014-11-18 01:15 AM
Hi
''The ucontroller on the board (STM32L152RB) features 4kB of EEPROM at the address 0x08080000'' No it does not. It is probably a EEPROM emulation in Flash. '' However there are no functions to read a byte/word. What is the code to read a byte/word at a particular address in the range 0x08080000 - 0x08080FFF?'' It is probably EEPROM emulation in Flash. You can just read the memory locations. ''2) Before making a write operation on a byte/word, is it necessary to erase that byte/word before?'' It is probably EEPROM emulation in Flash. Either the EEPROM emulation takes care of this for you OR You must erase the whole Flash sector before writing to it.2014-11-18 01:47 AM
unsigned int var;
var = *(unsigned int *)0x08080000; 2) For L1 EEPROM there is automatic erase operation for the word, which is written to. You could write word, half-word, or byte directly without worrying if the word was erased before it. However, there is a limitation that you can't write 0x00000000 on some Cat. devices. If you need to write zero the only way to do it is to erase the word (0x00000000 is the erase state of the memory in this family).2014-11-18 02:42 AM
Hi
I take it back. The STM32L152RB does have built in EEPROM. Only just noticed it in the key features list. I did not think ST did any ARMs with EEPROM. Sorry, my mistake.2015-06-25 07:36 PM
Would you please tell me how to write data into the internal EEPROM of stm32L152?
Thank you for answer.2015-06-25 08:39 PM
Review the example code
STM32L1xx_StdPeriph_Lib_V1.3.0\Project\STM32L1xx_StdPeriph_Examples\FLASH\Data_Program\main.c