cancel
Showing results for 
Search instead for 
Did you mean: 

Flash Interrupt

paulsmitton9
Associate III
Posted on April 21, 2008 at 13:53

Flash Interrupt

2 REPLIES 2
paulsmitton9
Associate III
Posted on May 17, 2011 at 12:30

I have included the following code in the Flash Example 1 of the STM32 Library, to enable an interrupt after a flash operation:

Code:

NVIC_InitStructure.NVIC_IRQChannel = FLASH_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

FLASH_ITConfig(FLASH_IT_EOP, ENABLE);

I have also tried ensureing the HSI is on with:

RCC_HSICmd(ENABLE);

This causes an interrupt when debugging (via JTAG), but not when run from flash normally (i.e. after a reset).

Does anybody know what else I have to do to ensure there is always an interrupt.

paulsmitton9
Associate III
Posted on May 17, 2011 at 12:30

It seems that one must Unlock the flash before setting the interrupt flag. Thus:

Code:

FLASH_Unlock();

FLASH_ITConfig(FLASH_IT_EOP, ENABLE);

will interrupt (following a flash operation), but:

Code:

FLASH_ITConfig(FLASH_IT_EOP, ENABLE);

FLASH_Unlock();

Will not.

I'm not sure why this is though. I couldn't find any mention in the manuals.