Category: ARM Cortex-M

How to properly enable/disable interrupts in ARM Cortex-M? 9

How to properly enable/disable interrupts in ARM Cortex-M?

Point of this post is not how to use NVIC (Nested Vectored Interrupt Controller) in Cortex-M processors but how to disable/enable interrupts properly for your system to avoid strange behaviours in your code. Let’s assume you have 2 functions, which do some important stuff and they have to make sure that noone interrupts these 2 functions

ARM Cortex-M SCB ICSR register structure. From arm.com 1

Get interrupt execution status on Cortex-M processors

You might come to a situation when you wanna know if current code is executing inside interrupt or not. This might be handy when you do a library and you have one function which you wanna call in interrupt handler for specific event or without interrupt handler, buf wanna execute something specific in function only if you are currently in interrupt. You can create 2 different functions of course, but what if you have one very big function, and for...