cancel
Showing results for 
Search instead for 
Did you mean: 

Disable interrupts

isaac
Associate II
Posted on November 21, 2017 at 05:47

STMF4 is running and using some of the interrupts.

A a new piece of code needs to be protected from all interrupts but a specific one, which has the highest priority in this application.

The trivial solution: 

Go through the entire NVIC, disable every interrupt which is enabled besides the mentioned one, remember these interrupts and at the end of the code enable those interrupts. 

Is there a nicer solution ( RTOS is not used) ?

Maybe something that utilize the fact that it is the highest level interrupt?

Thanks,

#stm32-interrupts
3 REPLIES 3
David SIORPAES
ST Employee
Posted on November 21, 2017 at 10:00

You can configure BASEPRI register with:

void __set_BASEPRI ( uint32_t basePri );

This allows you to disable all interrupts with priority level value bigger or equal to a given threshold.

See 

https://www.keil.com/pack/doc/CMSIS/Core/html/group__Core__Register__gr.html#ga360c73eb7ffb16088556f9278953b882

AvaTar
Lead
Posted on November 21, 2017 at 10:14

I suggest to go to

, and read/download the M4 technical reference manuals - especially the interrupt section.

The ST manuals leave this out, usually.

Then read the F4 ref manual for specifics, and assign your interrupt priorities appropriately.

Posted on November 22, 2017 at 01:42

Could you configure the preemption levels to create the fencing you want, use SCB->SHP to setup where the SVCHandler falls in the hierarchy and then execute the critical code via the SVC?

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