S32K148 - interrupts disable/enable

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K148 - interrupts disable/enable

148 Views
Contributor III

Hello,

Assume I have following code sequence:

1. disable_interrupts()

2. some code

3. disable_interrupts()

4. some code

5. enable_interrupts()

6. some code

7. enable_interrupts()

disable_interrupts() is done by __asm("cpsid i")

enable_interrupts() is done by __asm("cpsie i")

When will interrupts become enabled back in the above sequence, at 5. or at 7.? Does S32K148 keep track of nested "cpsid" and "cpsie"?

Kind regards,

Jakub

Tags (1)
3 Replies

57 Views
Contributor III

It's safe in the sense that the documentation doesn't state not to do it.

If you want to enable interrupt nesting, calling CPSIE inside the ISR (like you would on an S12X) is not the way to go, since PRIMASK and FAULTMASK are  unchanged upon exception entry. It won't have any effect. You can make use of the priority levels. Higher priority exceptions can interrupt lower priority exceptions.

If you want to prevent interrupts from interrupting your ISR, you can safely call CPSID and then re-enable with CPSIE when you're done.

0 Kudos

57 Views
Contributor III

CPS Instructions in the ARMv7-M architecture directly influence PRIMASK and FAULTMASK registers. No nesting is performed.

See also ARMv7-M reference manual section B5.2.1.

57 Views
Contributor III

Thank you.

Is it safe to call those instructions from ISR?

0 Kudos