Skip to main content
WSpar.1
Associate III
August 26, 2021
Question

Project with EEPROM emulator stuck when handling an interrupt

  • August 26, 2021
  • 4 replies
  • 2508 views

Hi all,

I'm need to remember a motorspeed on a custom board with an stm32g431KBT microcontroller.

So I downloaded this package https://www.st.com/en/embedded-software/x-cube-eeprom.html and manage to compile the project.

I carefully started with just the `EE_Init(EE_CONDITIONAL_ERASE)` function, but my microcontroller get stuck after an interrupt trigger of my rotary switch.

Also reset of the microcontroller doesn't seems to run my code anymore. Only with a reprogram I get my program back.

I think something is wrong with my memory mapping.

The ST example has an extra CCMSRAM section, but I don't think this can be my issue here:

0693W00000DqWNwQAN.pngThe EEPROM emulation in my project has starting address 0x08010000U

This is the memory map of my project:

0693W00000DqWOuQAN.pngI'm a bit surprised by the 71% here, it's a small simpel code project.

Do I have to configure the EEPROM emulator as starting address after 0x08020000?

Or is CCMSRAM section really necessary?

As soon as I comment out EE_Init() my project is working fine.

It looks as if my code with EEPROM emulation doesn't know how to exit interrupts and also corrupts my code.

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
August 26, 2021

Hard to say, but just be aware that blocking functions, or those dependent on delay loops using systick, should not be used under interrupt context, this includes HAL callbacks into your own code, and functions they might in turn call or depend on.

Might be time to learn how the Flash memory functions

You also don't want the EEPROM Emulation to be using flash sectors in the middle of your active code space. You need to park them outside, or carve a hole to accommodate them.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TDK
August 26, 2021

Seems like your code occupies part of the same flash being used for EEPROM emulation.

A reset will start with running your own code, provided BOOT0 is down, or similar. If that's not happening, perhaps it's because the EEPROM emulation erased part of it. Examining memory with STM32CubeProgrammer would confirm.

"If you feel a post has answered your question, please click ""Accept as Solution""."
WSpar.1
WSpar.1Author
Associate III
August 27, 2021

When I compile and program my project with the EEPROM package included, my Flash starts to free up space at 0x0801A140

0693W00000DlRkMQAV.jpg 

So before my EEPROM start address was 0x08010000 and clearly overlapping.

Now I changed it to 0x0801A190 but the main code isn't running anymore.

For EEPROM emulation I need 2 pages of 2kbytes, 256 words of 64 bits

TDK
August 27, 2021

The EEPROM flash page must be located in a page not used by your code. It can't start midway through a page.

"If you feel a post has answered your question, please click ""Accept as Solution""."