cancel
Showing results for 
Search instead for 
Did you mean: 

Getting possible error of FLASH write operation

Tobe
Senior III

I need to check to outcome of a FLASH write operation. EOP would indicate, that it was successfully, but it needs the interrrupt to be enabled to show the outcome. Oh well, then i use the error flag instead (because i dont want to use interrupts). But then AGAIN it needs an interrupt enabled to work. Why cant there be just a simple flag without needing of other things??? 

stm err omfg.jpg

 

10 REPLIES 10

You don't need to enable the FLASH interrupt at NVIC level, so no actual interrupts will be fired.

> Why cant there be just a simple flag without needing of other things??? 

Good question. I'd love to hear the author of this module to comment, but that won't happen.

JW

But then the flag is not set.

 

The description you pointed out does not call for interrupts to be enabled at NVIC, only the enable bits in FLASH_CR to be set.

Are you saying you have a different experience? That you did not enable interrupts in NVIC, set FLASH_CR.EOPIE/ERRIE, yet still seen no EOP/ERR being set in FLASH_SR?

JW

I debugged it... no flag to see. But i must say, that i did not erase the page. I read somewhere, that writing 0x00 is still possible. It works on the first double word, but not after it.

proof.jpg

You haven't set FLASH_CR.EOPIE/ERRIE. So, exactly as documented, neither FLASH_SR.EOP nor xxERR is set.

Set FLASH_CR.EOPIE/ERRIE and retry. As long as you don't enable FLASH interrupt in NVIC, interrupt service routine is not run.

JW

I dont think that i want to disable interrrupts, as i use two of them. But on the other hand, im thinking if i should  disable interrupts when writing to flash?

Pavel A.
Evangelist III

To check for flash write outcome (besides of the error flags): compare the source and the flash content. Because, things happen.

 

It might be an idea, because the documentation is kinda useless. I now got a flag of success and two flags of failure at the same time... Errors were cleared just before!

wtf.jpg

There are three levels at which you enable/disable interrupts

1. individual interrupt sources within a peripheral (e.g. in timer, you enable/disable them by setting bits in TIMx_DIER);

2. then all enabled interrupts of one peripheral are ORed together and output of that OR is one of the inputs to NVIC, other inputs are from other peripherals;

waclawekjan_0-1702504707074.png

all these can be individually disabled (they are by default) or enabled (e.g. using NVIC_EnableIRQ() )

3. in processor, interrupts can be enabled/disabled globally (using __enable_irq()/__disable_irq()); when disabled globally, none of the peripherals enabled in NVIC causes interrupt

 

Here, I am not talking about disabling interrupts globally (3.). I am talking about not enabling (i.e. leaving in default disabled state) the particular FLASH interrupt at NVIC level (2), so that even if you enable interrupts at the FLASH module level (1), no interrupts from FLASH will reach processor (as they are disabled at NVIC level (2)), while other interrupts are still enabled.

JW