cancel
Showing results for 
Search instead for 
Did you mean: 

Flash End-Of-Write Interrupt

kleshov
Associate II
Posted on March 12, 2009 at 09:31

Flash End-Of-Write Interrupt

20 REPLIES 20
kleshov
Associate II
Posted on September 12, 2006 at 11:27

Hello,

I am trying to implement in-application flash programming using the flash end-of-write interrupt. My interrupt service routine triggers only on the first write. All subsequent writes to flash do not trigger an interrupt, although the interrupt pending bit INTP in the flash control register FLASH_CR0 gets set. Other interrupts keep working as expected.

The Flash Programming Reference Manual mentions the end-of-write interrupt only very briefly. A google search on interrupt-driven flash programming for STR7 didn't return anything.

What am I doing wrong? Or have I discovered a bug in the silicon?

Thanks for any hints,

- mike

anis2
Associate II
Posted on September 12, 2006 at 15:01

Hello,

You have to reset the INTP bit on your interrupt service routine.

Rgds,

Bouha.

kleshov
Associate II
Posted on September 12, 2006 at 16:02

I do reset the INP bit in the ISR. Besides, if I didn't clear the interrupt pending bit, I would expext the ISR to be reactivated immediately on exit, exactly as it happens with interrupts from other peripherals.

Can anyone confirm that interrupt-driven flash programming works? Can my problems be related to single-stepping through the code in the debugger?

anis2
Associate II
Posted on September 13, 2006 at 06:05

Hi,

I verify it and it works fine whith the library flash routines. I guess you aren't using the library flash routines?

Rgds,

Bouha.

kleshov
Associate II
Posted on September 13, 2006 at 06:33

No, I am not using the STR71x standard library. I checked the library source and found that it does not use flash end-of-write interrupt, so the library cannot expose that problem.

I can work around the problem by not using interrupts for flash programming in my application. But it would be much better if flash behaved as advertised, so that I could write a self-contained interrupt-driven driver for flash programming.

Still looking for hints,

- mike

anis2
Associate II
Posted on September 13, 2006 at 11:00

It's simple, you have just to add the following code line to enable the interrups from the Flash and use the standard library Flash routines (Write & Erase)

FLASHR->CR0 |= 0x200000;

And in the 71x_it.c file add the following line code to clear the Flash interrupt pending bit.

FLASHR-> &= ~0x100000;

Hope this helps you,

Rgds

kleshov
Associate II
Posted on September 13, 2006 at 12:34

Thank you for the suggestion. I know it is simple. I have read the manuals and the library's source code. I am confident that my code is correct since it works if I don't rely on flash end-of-write interrupt and call my interrupt handler from a loop that polls the INTP bit.

My question is: has anyone used flash end-of-write interrupt? Does it actually work?

- mike

kleshov
Associate II
Posted on September 13, 2006 at 13:53

After some investigation I noticed the following:

1) My interrupt-driven code works as expected if I don't interrupt it with the debugger.

2) If I comment out the line that clears the INTP bit in my ISR, the program still works as expected. That is, when no flash write operation takes place, the ISR is not called. Conversely, the ISR is called after each flash write operation.

All of that indicates that the INTP bit is not a replica of the flash module's interrupt request line, unlike with other peripherals. It is merely an indication that the flash module has generated an interrupt request. Moreover, it appears that the flash module only asserts its interrupt request line for a certain period. If the EIC cannot accept the interrupt during that period (e.g. the corresponding bit in IER0 is not set or the MCU is in the debug state) then the interrupt is lost.

If anyone from ST is reading this, could you please convey that information to someone who can put it in the relevant documentation.

pete3
Associate II
Posted on September 13, 2006 at 14:18

New here, aren't you?