以下是官方的例程:
/* make sure that no UART transfer is on-going */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET);
/* make sure that UART is ready to receive
* (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_REACK) == RESET);
/* set the wake-up event:
* specify wake-up on RXNE flag */
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK)
{
Error_Handler();
}
/* Enable the UART Wake UP from stop mode Interrupt */
__HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);
/* about to enter stop mode: switch off LED */
__HAL_RCC_PWR_CLK_ENABLE();
/* enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&UartHandle);
/* enter stop mode */
BSP_LED_Off(LED3);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
/* ... STOP mode ... */
SystemClock_Config();
/* at that point, MCU has been awoken: the LED has been turned back on */
/* Wake Up based on RXNE flag successful */
BSP_LED_On(LED3);
HAL_UARTEx_DisableStopMode(&UartHandle);
/* wait for some delay */
HAL_Delay(1000);
/* Inform other board that wake up is successful */
if (HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer1, COUNTOF(aTxBuffer1)-1, 5000)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(1000);
BSP_LED_Off(LED3);
/*##-2- Wake Up second step ###############################################*/
/* make sure that no UART transfer is on-going */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET);
/* make sure that UART is ready to receive
* (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_REACK) == RESET);
/* set the wake-up event:
* specify wake-up on start-bit detection */
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK)
{
Error_Handler();
}
/* Enable the UART Wake UP from stop mode Interrupt */
__HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);
/* about to enter stop mode: switch off LED */
BSP_LED_Off(LED3);
/* enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&UartHandle);
/* enter stop mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
/* ... STOP mode ... */
/* at that point, MCU has been awoken: the LED has been turned back on */
/* Wake Up on start bit detection successful */
HAL_UARTEx_DisableStopMode(&UartHandle);
/* wait for some delay */
HAL_Delay(100);
/* Inform other board that wake up is successful */
if (HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer2, COUNTOF(aTxBuffer2)-1, 5000)!= HAL_OK)
{
Error_Handler();
}
可以的。en.DM00355687这个文件里有提到可以到stop下唤醒。且en.stm32cubel0的例程里有UART_WakeUpFromStop的代码。我是直接跑的,但就是唤醒不了!!不知道错在哪里!!
以下是官方的例程:
/* make sure that no UART transfer is on-going */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET);
/* make sure that UART is ready to receive
* (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_REACK) == RESET);
/* set the wake-up event:
* specify wake-up on RXNE flag */
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK)
{
Error_Handler();
}
/* Enable the UART Wake UP from stop mode Interrupt */
__HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);
/* about to enter stop mode: switch off LED */
__HAL_RCC_PWR_CLK_ENABLE();
/* enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&UartHandle);
/* enter stop mode */
BSP_LED_Off(LED3);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
/* ... STOP mode ... */
SystemClock_Config();
/* at that point, MCU has been awoken: the LED has been turned back on */
/* Wake Up based on RXNE flag successful */
BSP_LED_On(LED3);
HAL_UARTEx_DisableStopMode(&UartHandle);
/* wait for some delay */
HAL_Delay(1000);
/* Inform other board that wake up is successful */
if (HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer1, COUNTOF(aTxBuffer1)-1, 5000)!= HAL_OK)
{
Error_Handler();
}
HAL_Delay(1000);
BSP_LED_Off(LED3);
/*##-2- Wake Up second step ###############################################*/
/* make sure that no UART transfer is on-going */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_BUSY) == SET);
/* make sure that UART is ready to receive
* (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
while(__HAL_UART_GET_FLAG(&UartHandle, USART_ISR_REACK) == RESET);
/* set the wake-up event:
* specify wake-up on start-bit detection */
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK)
{
Error_Handler();
}
/* Enable the UART Wake UP from stop mode Interrupt */
__HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);
/* about to enter stop mode: switch off LED */
BSP_LED_Off(LED3);
/* enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&UartHandle);
/* enter stop mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
/* ... STOP mode ... */
/* at that point, MCU has been awoken: the LED has been turned back on */
/* Wake Up on start bit detection successful */
HAL_UARTEx_DisableStopMode(&UartHandle);
/* wait for some delay */
HAL_Delay(100);
/* Inform other board that wake up is successful */
if (HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer2, COUNTOF(aTxBuffer2)-1, 5000)!= HAL_OK)
{
Error_Handler();
}
刚好我也在调这个程序 我用的是L452,Dome应该类似吧 我的Dome是需要两块板子 不过有一块是不需要进低功耗的,所以 可以用电脑串口助手代替,不过唤醒时 发送 的内容有要求。 还有就是 我换个串口 想用其他串口唤醒 就不行 只有UART4才能唤醒 感觉 ST低功耗这方面的做的不好 提供的支持也不足,PDF讲的太笼统
改IO中断 没意思,uart在stop下手册上写有可以唤醒的。这才是这个片子的特性
会不会是PC端的唤醒命令有问题。
评分
查看全部评分
评分
查看全部评分
但你可以在进入STOP模式之前,把RX脚设置成IO中断唤醒就可以了。
当然,会丢失串口的开始的几个数据。
评分
查看全部评分
我做过进入stop前把串口设置为中断,缺点就是需要一段唤醒码
评分
查看全部评分
评分
查看全部评分
这里的32L011,STOP模式下可以被USART1/USART2/LPUART1唤醒,不过还要与
相应的EXTI中断线配置起来。
评分
查看全部评分