STM32L151RCTxA RTC Stop Mode UART/DMA
Hi all,
I am using the STM32L151RCTxA MCU with STM32CUBEMX.
I have configured FREERTOS, a UART using DMA and tickless IDLE.
I am attempting to run my MCU in low power mode.
My first misunderstanding is how to get the MCU to trigger the PreSleepProcessing and PostSleepProcessing functions. Should it not be a case of simply suspending all my tasks with osThreadSuspendAll()?
If I bypass these functions and manually call the sleep functions I am successful calling HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
I would like to go one step further and go into STOP RTC mode. I have configured an RTC to wake up every 10s.
I am sending a command to a LoRa module to tell it to go to sleep. I am expecting an 'OK' response when it times out so that I can do some processing. If I call HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); when I wake up via the RTC I seem to have lost my connection to the module and have to reset it to communicate on it again. I have read that I must deinit the UART and renitialise again on wakeup but that does not seem to help.
Has anybody experienced similar and found a way around it? My code to enter STOP mode is below.
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x5F46, RTC_WAKEUPCLOCK_RTCCLK_DIV16);HAL_UART_MspDeInit(&huart3); //if (HAL_UART_DeInit(&huart3) != HAL_OK) //{ // _Error_Handler(__FILE__, __LINE__); //} HAL_SuspendTick(); /* Enter Stop Mode */ //HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); HAL_ResumeTick(); /* Configures system clock after wake-up from STOP: enable HSI, PLL and select PLL as system clock source (HSI and PLL are disabled automatically in STOP mode) */ SystemClockConfig_STOP();On wakeup I simply initialise the UART and wait for the OK.
/* Disable Wakeup Counter */ HAL_RTCEx_DeactivateWakeUpTimer(&hrtc); HAL_UART_MspInit(&huart3); //MX_USART3_UART_Init(); //if (HAL_UART_Init(&huart3) != HAL_OK) //{ // _Error_Handler(__FILE__, __LINE__); //}I would really appreciate any help here. I feel I am close but there is some final thing I am not understanding
