invoking __disable_irq() within an ISR on LPC546xx

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

invoking __disable_irq() within an ISR on LPC546xx

1,137件の閲覧回数
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? 

ラベル(2)
0 件の賞賛
返信
1 返信

951件の閲覧回数
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 件の賞賛
返信