2022-08-15 12:20 PM
Hello all,
After successfully entering Stop mode with my STM32F051, I cannot wake it up. I have referenced this article heavily, but cannot get it to work for me (I see that it is for an F072B): https://github.com/STMicroelectronics/STM32CubeF0/blob/master/Projects/STM32F072B-Discovery/Examples/UART/UART_WakeUpFromStop/Src/main.c
I have been using this method of wakeup:
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_ADDRESS; WakeUpSelection.AddressLength = UART_ADDRESS_DETECT_7B;
WakeUpSelection.Address = 0x29;
__HAL_UART_ENABLE_IT(&UartHandle, UART_IT_WUF);
HAL_UARTEx_EnableStopMode(&UartHandle);
After entering Stop mode by sending "stop", how can I wake it up? I cannot get "HAL_UART_RxCpltCallback" to call again. Is that even how I can wake it up, or how do I send 0x29?
uint8_t Rx_data[4]; // creating a buffer of 4 bytes
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
HAL_UART_Receive_IT(&huart1, Rx_data, 4);
if (Rx_data[0] == 's' && Rx_data[1] == 't' && Rx_data[2] == 'o' && Rx_data[3] == 'p') {
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,
PWR_STOPENTRY_WFI);
}
if (Rx_data[0] == 'w' && Rx_data[1] == 'a' && Rx_data[2] == 'k' && Rx_data[3] == 'e') {
SystemClock_Config();
HAL_UARTEx_DisableStopMode(&huart1);
}
}
Any help or tips are appreciated. Thank you in advance!
2022-08-15 03:45 PM
I think wakeup pin connected to rx maybe needed in clock stopped.mode, as unclocked or self clocked peripheral maybe needed to kick back the main oscillator. In STM33L or U series, there is LPUART as low.power uart which can wakeup on incoming RX data byte and catch it value. If bitrate remains reasonable.
2022-08-15 10:43 PM
And who will call these?
2022-08-16 05:24 AM
1: USARTx_RCC_CONFIG(RCC_USARTxCLKSOURCE_HSI);
This command is not applicable to the STM32F051, but I still set the UART clock source to HSI using PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_HSI;
2: if (HAL_UARTEx_StopModeWakeUpSourceConfig(&UartHandle, WakeUpSelection)!= HAL_OK){
I do have this command, but I forgot to include that in my question. I was trying to not flood the page with code:)