2021-08-26 02:57 PM
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:
The EEPROM emulation in my project has starting address 0x08010000U
This is the memory map of my project:
I'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.
2021-08-26 03:11 PM
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.
2021-08-26 04:12 PM
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.
2021-08-27 06:39 AM
When I compile and program my project with the EEPROM package included, my Flash starts to free up space at 0x0801A140
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
2021-08-27 12:34 PM
The EEPROM flash page must be located in a page not used by your code. It can't start midway through a page.