STM32F042在停止模式下,用HALL库,RTC和外部中断都可以唤醒。
用USART也可以在不丢数据的情况下唤醒。
有谁用过CAN唤醒,找不到资料呀。
只看到将CAN接收脚临时改成外部中断,唤醒后再恢复成CAN,这样当前CAN数据会丢失。
我需要每接收一帧数据就唤醒,再立马进STOP模式。
HALL库没找到象USART那样的唤醒函数。
/* set the wake-up event:
* specify wake-up on RXNE flag */
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY; //; //UART_WAKEUP_ON_STARTBIT
if (HAL_UARTEx_StopModeWakeUpSourceConfig(&huart1, WakeUpSelection)!= HAL_OK)
{
//Error_Handler();
}
/* Enable the UART Wake UP from stop mode Interrupt */
__HAL_UART_ENABLE_IT(&huart1, UART_IT_WUF);
/* enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&huart1);
HAL_UART_Receive_IT(&huart1, aU1RxBuf, 1);
//CAN
//__HAL_CAN_ENABLE_IT(&hcan,CAN_IT_WKU);
//HAL_CAN_Receive_IT(&hcan, CAN_FIFO0);
//MX_RTC_Init();
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); //wake up1 »½ÐÑ
/* Enter Stop Mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /////////
/* Configures system clock after wake-up from STOP: enable HSI and PLL with HSI as source*/
//SYSCLKConfig_STOP();
SystemClock_Config();
|