2023-02-15 07:36 AM
Hello everyone,
I'm working on a project with an STM32L072CBT6.
In my project, i use a LPUART1 and USART1 to send and receive data. Connected to this i use a DMA to get data.
My projet works fine so i try to implement stop mode to reduce consumption.
In a previous project i have used stop mode and LPUART1 to wake the MCU so i have implement the same line of code for this project.
But for this project, impossible to wake-up my MCU when data occur on my LPUART (i only need LPUART data wakeup the module). My MCU wakeup well when i trigger an external event on interrupt pin but when a data occur on LPUART nothing happen.
If i check all ressources which talk about use LPUART and stop mode my implementation SEEMS to be correct.
I add below information about my implementation.
Any help or directions are appreciated, thanks in advance!
void stm32_low_power_setup(void)
{
//make sure that no UART transfer is on-going
while (__HAL_UART_GET_FLAG(&huart1, USART_ISR_BUSY) == SET) ;
// make sure that UART is ready to receive
while (__HAL_UART_GET_FLAG(&huart1, USART_ISR_REACK) == RESET) ;
//make sure that no UART transfer is on-going
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_BUSY) == SET) ;
// make sure that UART is ready to receive
while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_REACK) == RESET) ;
HAL_SuspendTick();
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableUltraLowPower(); // Ultra low power mode
HAL_PWREx_EnableFastWakeUp(); // Fast wake-up for ultra low power mode
HAL_SuspendTick();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
HAL_GPIO_WritePin(ALIM_I2C_GPIO_Port, ALIM_I2C_Pin, 1);
UART_WakeUpTypeDef wakeup;
wakeup.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, wakeup);
__HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_WUF);
HAL_UARTEx_EnableStopMode(&hlpuart1);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI);
}
Best regards,
MLam
2023-02-21 03:03 AM
Hello @MLam ,
The DMA channel is convenient for transmission of data, and is power-efficient during reception. The downside is that in DMA mode the LPUART cannot take advantage of wakeup from Stop mode. The reason is that after wakeup event the DMA has difficulty picking up on the ongoing communication.
For more explanation I advise you take a look AN4635 and precisely section 4.3 and section 4.4.2.
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.