1. 近日使用N32WB031做串口低功耗唤醒验证。发现在设备进入sleep后无法被触发,但在进入sleep前,发送串口信息就可以触发串口中断。一旦进入sleep就完了。
demo 参照工程目录 :N32WB301\N32WB03x_SDK_V1.3\projects\n32wb03x_EVAL\peripheral\LPUART\WakeUpFromStop\MDK-ARM
main()的程序:
/*##-1- Wake Up second step ###############################################*/
printf("\n\r##-1-Start Bit Detection Wake-Up##\n\r");
/* Set the Wake-Up Event: specify wake-up on start bit */
LPUART_ConfigWakeUpMethod(LPUARTy, LPUART_WUSTP_STARTBIT);
/* Enable the LPUARTx Wake UP from STOP Mode Interrupt */
LPUART_ConfigInt(LPUARTy, LPUART_INT_WUF, ENABLE);
/* Enable MCU Wake-up by LPUARTx */
LPUART_EnableWakeUpStop(LPUARTy, ENABLE);
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_PWR, ENABLE);
/* Enter STOP Mode */
PWR_EnterSLEEPMode(PWR_SLEEPENTRY_WFI);
/* ... STOP Mode ... */
/* Wake Up based on Start Bit Detection successful */
LPUART_EnableWakeUpStop(LPUARTy, DISABLE);
/* Output a message on LPUARTy using printf function */
printf("\n\rStart bit detection wake-up successful\n\r");
/*##-2- Wake Up second step ###############################################*/
printf("\n\r##-2-RXNE Detection Wake-Up##\n\r");
/* Set the Wake-Up Event: specify wake-up on RXNE flag */
LPUART_ConfigWakeUpMethod(LPUARTy, LPUART_WUSTP_RXNE);
/* Enable the LPUART Wake UP from STOP Mode Interrupt */
LPUART_ConfigInt(LPUARTy, LPUART_INT_WUF, ENABLE);
/* Enable MCU Wake-Up by LPUARTx */
LPUART_EnableWakeUpStop(LPUARTy, ENABLE);
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_PWR, ENABLE);
/* Enter STOP Mode */
PWR_EnterSLEEPMode(PWR_SLEEPENTRY_WFI);
/* ... STOP Mode ... */
/* Wake Up based on RXNE Detection successful */
LPUART_EnableWakeUpStop(LPUARTy, DISABLE);
/* Output a message on Hyperterminal using printf function */
printf("\n\rRXNE detection wake-up successful\n\r");
#else
#endif
} |