cancel
Showing results for 
Search instead for 
Did you mean: 

PRIMASK bit on after enabling interrupts.

kalbar666
Associate II
Posted on July 07, 2015 at 20:47

Hi all,

I am using STM32F407 chip with GCC toolchain.

I have a trouble with my code. I wrote a function that needs an exclusive access to variables (I want to have ability to call this function from interrupts as well as from main loop code), so I am disabling interrupts whenever code reaches critical sections. The thing is that whenever I am using disable_irq()/enable_irq() functions, interrupts sporadically do not get turned on again and stay disabled (PRIMASK = 1). I am still while developing and debugging my code but I would like to ask if there any other possibility for PRIMASK to get set to 1 other than using ''asm volatile (''cpsid i'');'' line? I was looking into datasheet/reference/programmers manuals, but so far no luck.

#stm32f4
2 REPLIES 2
Posted on July 07, 2015 at 22:29

Seem to recall it's not something that's inherently stacked by the processor on the Cortex parts.

I guess if you used a mutex, or provided some sort of audit trail you might be able to figure out who failed to re-enable.

If you're using an RTOS, it could stack things. Look also for MSR usage.

You'd also want to make sure you've covered all exit paths from a routine. Again, some sort of audit trail might permit you to track any commonality in the failure.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
kalbar666
Associate II
Posted on July 08, 2015 at 10:13

You were right. I have checked my code again and there was a possibility for it to exit before re-enabling interrupts back again. Silly mistake. Thank for a clue!