Disable IRQ on STM32

后端 未结 2 978
不思量自难忘°
不思量自难忘° 2020-12-22 00:14

Is there any way to disable all irq from Cortex M3 MCU except one ?

My issue is that I have a system running several kinds of irq with various priority levels and I

相关标签:
2条回答
  • 2020-12-22 00:21

    Use the BASEPRI register to disable all interrupts below the specified priority level.

    This is a core register, described in the Cortex-M3 Programming Manual.

    CMSIS provides the __get_BASEPRI() and __set_BASEPRI() functions to manipulate its value.

    Note that bits 7-4 are used, the priority value must be shifted left by 4. To disable all interrupts with priority 1 or lower, use

    __set_BASEPRI(1 << 4);
    

    and to enable all, set it to 0

    __set_BASEPRI(0);
    

    You should of course set interrupt priorities accordingly, ensuring that no other interrupt has priority 0.

    0 讨论(0)
  • 2020-12-22 00:34

    Other than by disabling all the enabled interrupts you don't want, no.

    __disable_irq() is implemented as CPSID I, which turns off all exceptions which can have a priority set (those configured in the NVIC), it achieves this by changing the PRIMASK register (setting bit 0) within the CPU. There is no way to tell this to only enable a specific interrupt.

    0 讨论(0)
提交回复
热议问题