invoking __disable_irq() within an ISR on LPC546xx

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

invoking __disable_irq() within an ISR on LPC546xx

1,162 Views
belmontbob59
Contributor IV

I want to perform an atomic operation on a memory buffer that can be accessed from multiple ISRs. I was thinking of  providing a function that would be called from these ISRs to perform the atomic operation. i.e. :

void foo(void) {     int was_masked = __disable_irq();     /* ... perform atomic operation ... */     if (!was_masked)         __enable_irq(); }

the function 'foo' would be invoked from multiple ISRs.

Is this safe / advisable to do so ? I've read from another thread (see below) that this is not safe. The sentence that brings me concern is :  "As a rule, one should NOT be altering PRIMASK within an interrupt-service routine -- ONLY fiddle with interrupt controls within 'main code' (to protect atomic operations): NOT in interrupt context --"

Could someone please provide me with guidance ?  thank you.

How does “CPSID” (used to control interrupts) work? 

Labels (2)
0 Kudos
Reply
1 Reply

976 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Bob belmont,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
It's available, however, I'd highly recommend you to adopt increasing the priority of the interrupt instead of configuring the PRIMASK bit to against other interrupt interfere the current interrupt.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply