How to protect against re-entrancy?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I need to protect a routine from re-entrancy, which may be called from the main loop and from ISRs. My routine itself is dependent on the services of an ISR (but this ISR does not try to call my routine). We are not using an RTOS.

My question: Is there something like a semaphore or mutex or spinlock available from the DAVE Apps/libraries? Or a test-and-set macro?

Thanks.
0 Likes
4 Replies
Not applicable
Hi,

I think checking the respective interrupt flags will do since every interrupt (NVIC) has its corresponding flag.

BR,
Zain
0 Likes
Not applicable
If two ISRs are active, wouldn't they block each other and nothing would run? Also, there isn't an interrupt flag associated with the main loop.
0 Likes
User5581
Level 3
Level 3
I have been using the CMSIS _LDREX() and _STREX() calls to do this
0 Likes
Not applicable
Thanks! These look like they will work great. Haven't tried yet, but will as soon as I can.
0 Likes