2021-06-16 04:27 AM
Hi,
Recently I started working on stm32 microcontroller. I am trying to write/read data from Flash memory of stm32f070cb.
I have tried writing as well as reading data from internal flash memory using stm32f072 disco evaluation board and it is working fine.
Now I am trying to integrate the same code on the custom board having stm32f070cb MCU, but while erasing memory from flash initially before writing the data, I am facing hardfault error.
I have attached the code snippet. Please support to fix this issue.
Thanks & Regards.
Paneri.
2021-06-16 05:28 AM
Hello,
Welcome to STM32 Community!
I recommend you to have a look to the example under STM32Cube directory:
STM32Cube_FW_F0_V1.11.0\Projects\STM32F070RBNucleo\Examples\FLASH\FLASH_EraseProgram\
This example can help you to configure and use the FLASH HAL API to erase and program the internal Flash memory.
So, you can compare your own project with the one available in the cube package
Imen
2021-06-16 05:35 AM
Please post as code blocks ( </> ) rather than images, I can't use images on several devices.
Have a proper Hard Fault handler to quickly identify what exactly the processor has an issue with. I've post many examples.
Check alignment, check you are going out-of-bounds.
Add instrumentation so you understand what's happening.
Sanity check addresses.
Check you're not erasing memory your code is executing from.
2021-06-16 05:53 AM
> EraseInitStruct.PageAddress = StartPage;
You're providing a page number to something that asks for a page address.