cancel
Showing results for 
Search instead for 
Did you mean: 

None-interruptable functions

Zainka
Associate III
Posted on March 03, 2015 at 01:06

Hello

This might be a silly  ''everybody knows that''-question (except me) but are there any atributes/methodes that will prevent a function from beeing interrupted by interrupts while running?

I have a set of functions that deals with ringbuffers where one function puts data into the buffer and another is reading from the same buffer if any data is available. The buffer are controlled by two indexes, and if an interrupt is trying to put something into the buffer while the main system is trying to read its content, possible hickups might occure. There will always be only one reading the buffer, but there might be several that wants to put something into the buffer.

I remember in my earli years when dealing with 8bit AVRs (sorry for mentioning them herein) I simply stored the status register before clearing interrupt enable bit when I wanted to prevent interrupts to be executed under special circumstances, when done I restored the SREG register again. This worked like a charm but I wonder if there are any other and better way to achiev this.

Thanks in advance  

Oh.. I use the Sourcery_CodeBench_Lite_for_ARM_EABI toolset for compiling

1 REPLY 1
Posted on March 03, 2015 at 01:33

In Libraries\CMSIS\Include\core_cmFunc.h, which gets pulled in via other includes in the build process, there are definitions for __disable_irq() and __enable_irq(), at an assembler level you have ''cpsie i'' and ''cpsid i''

If you're looking for a good book covering the CPU try one of Joseph Yiu's

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