cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable interrupts with ST firmware library

stenasc
Senior
Posted on October 19, 2015 at 14:29

Hi Forum,

I am seeing some spurious results when running code and I think it may be interrupt related. To test, I need a quick way of enabling/disabling .

There are two types of interrupts running on our system, external (EXTI) and internal timer interrupts.

Will the following to the trick to enable and disable all interrupts or just the external ones.

Enable...

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

     

NVIC_Init(&NVIC_InitStructure);

Disable..

NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;

NVIC_Init(&NVIC_InitStructure);

If only external interrupts, how could one disable all?

Thank you.

Bob Carter

3 REPLIES 3
Posted on October 19, 2015 at 18:21

You should be able to enable/disable all the IRQ Handler in the Vector Table at the NVIC, individually. Shouldn't matter if it's the EXTI or TIM, etc.

System Handlers, like SysTick and Faults are different, ie the nIRQ is negative

You can enable/disable at a chip level __enable_irq() and __disable_irq(), aka cpsie i and cpsid i

Finally you can mask at a peripheral level.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stenasc
Senior
Posted on October 20, 2015 at 14:13

HI Clive,

Thanks for the reply. Will the following do it...

NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;

NVIC_Init(&NVIC_InitStructure);

or do I have to disable them individually using..

NVIC_DisableIRQ

 

 

Cheers

 

Bob

Posted on October 20, 2015 at 15:43

NVIC_Init() will need more parameters in the structure than shown, not sure if that's just the way you cut-n-pasted it.

NVIC_DisableIRQ() would look like a cleaner/simpler way to do it.

With the same pre-emption level other interrupts are not going to break into the current one. Normally they'd just tail-chain into the next one. Disabling one, that you're currently servicing, won't allow others to occur until you leave the handler.

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