cancel
Showing results for 
Search instead for 
Did you mean: 

Hard Fault error during flash page erase of stm32f070CB MCU.

PShah.11
Associate

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.

0693W00000Bb8nKQAR.png0693W00000Bb8obQAB.png0693W00000Bb8oHQAR.png0693W00000Bb8noQAB.png 

3 REPLIES 3
Imen GH
ST Employee

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

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

> EraseInitStruct.PageAddress = StartPage;

You're providing a page number to something that asks for a page address.

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