cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM for Cube MX STM32F301C8

Gz
Senior
Posted on August 07, 2017 at 09:13

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 #hal
6 REPLIES 6
Brian TIDAL
ST Employee
Posted on August 07, 2017 at 15:27

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

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/b2/94/a6/62/18/c0/4f/e6/DM00311483/files/DM00311483.pdf/jcr:content/translations/en.DM00311483.pdf

).

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

http://www.st.com/content/ccc/resource/technical/document/reference_manual/a5/e0/21/a3/78/00/41/1e/DM00094350.pdf/files/DM00094350.pdf/jcr:content/translations/en.DM00094350.pdf

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_EraseProgram: this example describes how to configure and use the FLASH HAL API to erase and program the internal Flash memory. 
  • 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.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Posted on August 08, 2017 at 03:19

If I am used to IAP function. Where can I find an example?

Posted on August 08, 2017 at 05:23

I try do it and debug in Keil program. The command message show ' Cannot access Memory'.

Posted on August 08, 2017 at 05:25

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_EraseProgram: this example describes how to configure and use the FLASH HAL API to erase and program the internal Flash memory. 
  • 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. 

Posted on August 08, 2017 at 10:12

Hi,

please describe the environment being used:

  • board (custom board or ST nucleo/disco/eval, precise reference of the board). As far as I know, ST does not provide Nucleo board nor Discovery board with STM32F301C8. Can you double check which STM32F3 is being used on your board?
  • debug probe (ULINK2, I-Jet, onboard ST-LINK or external ST-LINK V2 probe, etc.). Make sure not to use a clone probe (i.e. non-genuine probe). Make sure to have the latest probe firmware
  • probe connection mode: JTAG or SW
  • Keil uVision version

Check that the project configuration is aligned with HW configuration (e.g. JTAG or SW configuration)

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Posted on August 08, 2017 at 11:53

Thank you.