2023-02-14 11:34 PM
What I need to achieve: dry battery provides power for more than 5 years. There are only three external interfaces, two GPIO and one USART. Two GPIOs are used for external interrupt, and USART is used for communication with upper computer. The project uses STM32CubeMX to generate code. The LL selected by the template has a dry battery voltage of 3V and a capacity of 1000mAh. STM32L010K8T6 is powered on for initialization. The important codes are as follows:
LL_PWR_EnterLowPowerRunMode();
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE3);
Enter the STOP mode immediately after initialization. The code is as follows:
uart2_prepare_stop();
//LL_mDelay(1000);
PWR->CR &= ~PWR_CR_PDDS;
PWR->CR |= PWR_CR_CWUF;
LL_mDelay(1);
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__wfi();
LL_USART_DisableInStopMode(USART2);
Function uart2_prepare_stop code is as follows:
LL_USART_EnableIT_RXNE(USART2);
LL_USART_EnableClockInStopMode(USART2);
LL_USART_EnableIT_WKUP(USART2);
LL_USART_EnableInStopMode(USART2);
USART2 initialization code is as follows:
USART_InitStruct.BaudRate = 9600;
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
LL_USART_Init(USART2, &USART_InitStruct);
LL_USART_ConfigAsyncMode(USART2);
LL_USART_SetWKUPType(USART2, LL_USART_WAKEUP_ON_RXNE);
LL_USART_Enable(USART2);
uart2_prepare_stop();
The test results show that two external interrupts can wake up normally, but USART2 cannot wake up. The above codes are the settings related to turning on wake-up according to the manual references RM0451(/resource/en/reference_manual/rm0451-ultralowpower-stm32l0x0-advanced-armbased-32bit-mcus-stmicroelectronics.pdf).
Is there a register setting error in the above code? How to make USART2 wake up MCU when generating RXNE interrupt signal? Thank you!
2023-02-20 06:20 AM
Hello
First let me thank you for posting.
You may start from one of the examples you can find with the example selector in STM32CubeMx.
You can search by "UART_WakeUpFromStop".
Kind regards,
Semer.
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.