This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P401R不响应中断,当从LPM3被IO中断唤醒后

如题 ,  当从LPM3唤醒后, 进行I2C初始化,开始通过I2C口读从机数据时,不进I2C 中断函数。  这个问题怎么解决?

  • 根据您的描述,有可能是因为您在进入LPM3模式前,未清除SLEEPONEXIT 位。

    您需要调用SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; 否则只响应中断,中断退出后又休眠了。

    具体信息您可以参考

    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; // Set SLEEPDEEP
    SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk; // Set SLEEPONEXIT
    __DSB(); // Ensures SLEEPONEXIT is set
    // immediately before sleep
    __WFI(); // Go to sleep

  • 首先,谢谢回复。
    这一点已经知晓。 问题产生的详细背景是这样的。 正常上电后进行GPIO, IIC, UART的初始化,进行外围器件通信后,外设全部失能(DISABLE),配置唤醒中断然后进入LPM3模式, 当由IO中断唤醒后, 程序进行GPIO, IIC, UART的初始化操作,初始化完成后,此时IIC无法通信。 实际调试发现IIC的IFG中有置位,但不进中断服务函数。

  • 好了 ,自行解决了,也算是共享问题了。具体解决办法如下:

    在唤醒后要加入开全局中断的指令,代码示例如下:

        gvIF_SystemIOInterruptConfig();
        gvIF_SystemSleepClkConfig();
        MAP_PSS_disableHighSide();
        MAP_PCM_enableRudeMode();
        MAP_Interrupt_disableSleepOnIsrExit();
        MAP_PCM_gotoLPM3InterruptSafe();
        /*!< Here need to add the function below to enable global interrupt.*/
        Interrupt_enableMaster();
        /*!< Actual implemention is  " CPSIE  i" .*/
    

    具体调试流程也说明下:

    1.正常POR复位后,一切通信正常,LPM3唤醒后,IIC的UCBxIFG中有置位,但中断函数断点处未停,说明没进中断;

    2.同时串口printf函数能发送数据,但无法接收,因为接收是以中断进行的,实际UART中断函数中的断点也未停,说明也未进UART中断。

    3.从而断定,中断不响应。 实际查看CPU寄存器组中的PRIMASK,值为1. 【注:设置为1后关闭所有中断和除了HardFault异常外的所有其他异常,只有NMI、Reset和HardFault可以得到响应。】

    因此,在代码中加入实现如上部分描术。问题解决。

  • 这个问题,后续说明。 因为进入LPM3是调用了SDK中的代码

    PCM_gotoLPM3InterruptSafe(void)

    其具体实现如下:

        bool lpmHappenedCorrect;
    
        /* Disabling master interrupts. In Cortex M, if an interrupt is enabled but
         master interrupts are disabled and a WFI happens the WFI will
         immediately exit. */
        Interrupt_disableMaster();
    
        lpmHappenedCorrect = PCM_gotoLPM3();
    
        /* Enabling and Disabling Interrupts very quickly so that the
         processor catches any pending interrupts */
        Interrupt_enableMaster();
        Interrupt_disableMaster();
    
        return lpmHappenedCorrect;

    图示注释部分【/* Enabling and Disabling Interrupts very quickly so that the processor catches any pending interrupts */】有误导。实际唤醒后,全局中断被关了。希望TI修复SDK的问题。

  • 很高兴您能解决问题,谢谢分享解决方法
  • 谢谢您的反馈!



    dev.ti.com/.../group__pcm__api.html

    中有PCM_gotoLPM3InterruptSafe的相关说明

    Transitions the device into LPM3 while maintaining a safe interrupt handling mentality. This function is meant to be used in situations where the user wants to go to LPM3, however does not want to go to "miss" any interrupts due to the fact that going to LPM3 is not an atomic operation. This function will modify the PRIMASK and on exit of the program the master interrupts will be disabled.

    这个函数是会禁用全局中断的