2017-08-07 12:13 AM
Hi,
I would like to used EEPROM for STM32F301C8. I am used code below
uint32_t READ_FLASH(
uint32_t
DataAdr){ return *(int32u *)DataAdr;}void WRITE_FLASH(
uint32_t
DataAdr,uint32_t
Data){ erase_pages.PageAddress=DataAdr; erase_pages.NbPages=4; erase_pages.TypeErase=TYPEERASE_PAGES; HAL_FLASH_Unlock(); HAL_FLASHEx_Erase(&erase_pages, Error); HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, DataAdr, Data); HAL_FLASH_Lock();}It's not working. Please tell me about EEPROM or How I can learning if I am used to HAL library.
#stm #cube-mx #stm32-f3 #hal2017-08-07 06:27 AM
Hi,
As far as I know, there is no EEPROM in STM32F301x6/8 MCUs. EEPROM feature is available on STM32L0 and STM32L1 families. An EEPROM emulation feature is also available on STM32L4 (see
).In your code, the WRITE_FLASH() procedure will erase 4 pages of FLASH memory, i.e. 4 * 2048 bytes which is probably not what you want if trying to emulate EEPROM. See
for information about FLASH memory organization in STM32F301x6/8 MCUs.Examples of FLASH programming can be found in STM32Cube_FW_F3_V1.9.0\Projects folder for various STM32F3 MCU:
FLASH_WriteProtection: this example describes how to configure and use the FLASH HAL API to enable and disable the write protection of the internal Flash memory.
When using the HAL API in your code, make sure to deal with the return code of the API.
2017-08-07 08:19 PM
If I am used to IAP function. Where can I find an example?
2017-08-07 10:23 PM
I try do it and debug in Keil program. The command message show ' Cannot access Memory'.
2017-08-07 10:25 PM
Thank you very much. I found
Examples of FLASH programming can be found in STM32Cube_FW_F3_V1.9.0\Projects folder for various STM32F3 MCU:
FLASH_WriteProtection: this example describes how to configure and use the FLASH HAL API to enable and disable the write protection of the internal Flash memory.
2017-08-08 03:12 AM
Hi,
please describe the environment being used:
Check that the project configuration is aligned with HW configuration (e.g. JTAG or SW configuration)
2017-08-08 04:53 AM
Thank you.