S32K148 - interrupts disable/enable

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K148 - interrupts disable/enable

2,791 次查看
jakub_mielczare
Contributor IV

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

标记 (1)
3 回复数

2,700 次查看
Joey_van_Hummel
Contributor IV

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 项奖励
回复

2,700 次查看
Joey_van_Hummel
Contributor IV

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.

2,700 次查看
jakub_mielczare
Contributor IV

Thank you.

Is it safe to call those instructions from ISR?

0 项奖励
回复