cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to Flash - Fault: Mem Manage Handler

steve239955_st
Associate II
Posted on March 31, 2016 at 10:17

Hey there.

I am using a STM32L476RG. I'm implementing a module for handling erasing and writing of the internal FLASH memory.

In a test, I did the sequences as described in the reference manual for:

  • Flash unlock
  • Mass erase
  • Initiating flash programming
In mass erase, after starting it, I definitely wait for the busy flag being cleared.

Now in the last item of that list, as soon as I try to write one 64-bit word to a 64-bit-aligned address in the flash, I get this fault where it lands in the mem manage handler.

The FLASH StatusRegister is zero, i.e. no errors set.

The programming bit in the ControlRegister is set, the lock bit is cleared.

Interestingly, the MER2 bit, mass erase bank 2, is still set - is this normal, or should it have been automatically reset after completion?

What could cause this fault?

Is there some register telling about the cause of the fault? Have not found anything about that in the manual.

Thanks in advance.

#stm32l476-flash
1 REPLY 1
steve239955_st
Associate II
Posted on March 31, 2016 at 12:29

Solved: It was a wrong configuration of the MPU, the region I wanted to write to was part of a readonly region