cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575 Wakeup from UART in stop mode 1

Alan01252
Visitor

Hi all,

I've been struggling so much to get wake from uart working on this board. 

It looks like it should be simple, I have this code which I am pretty sure should be everything needed, but it just doesn't wake up when I send data to the serial port.

Can anyone see what I might be missing?

#include <Arduino.h>
#include <stm32u5xx_hal.h>
#include <stm32u5xx_ll_usart.h>
#include <stm32u5xx_ll_bus.h>
#include "CustomPinsHub.h"
static constexpr uint32_t LED_PIN = LED1_GRN;
uint8_t aRxBuffer[10];

void SystemClock_Config(); // forward

HardwareSerial stlinkSerial(rx_pin2debug, tx_pin2debug);

void setup()
{
    stlinkSerial.begin(115200);
    HAL_PWREx_EnableUltraLowPowerMode();
    pinMode(LED1_GRN, OUTPUT);
    digitalWrite(LED1_GRN, LOW);
    stlinkSerial.println("→ Setup complete. LED is ON.");
    delay(500);
    UART_HandleTypeDef *huart = stlinkSerial.getHandle();
    UART_WakeUpTypeDef wudata{};
    wudata.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
    HAL_UARTEx_StopModeWakeUpSourceConfig(huart, wudata);
    __HAL_RCC_PWR_CLK_ENABLE();
    __HAL_UART_ENABLE_IT(huart, UART_IT_WUF);
    HAL_UARTEx_EnableStopMode(huart);
    HAL_UART_Receive_IT(huart, (uint8_t *)aRxBuffer, 10);
    stlinkSerial.println("Entering STOP-1, waiting for any RX data to wake me..");
    stlinkSerial.flush();
    delay(500);
    HAL_SuspendTick();
    HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
    HAL_ResumeTick();
    SystemClock_Config();
    delay(500);
    stlinkSerial.println("✔ Woke up from STOP-1! Led off");
    delay(500);
    digitalWrite(LED_PIN, HIGH);
}

void loop()
{
    // nothing
}

 

4 REPLIES 4
Saket_Om
ST Employee

Hello @Alan01252 

Please refer to the example below: 

STM32CubeU5/Projects/NUCLEO-U575ZI-Q/Examples/UART/UART_WakeUpFromStopUsingFIFO at main · STMicroelectronics/STM32CubeU5 · GitHub

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.
Saket_Om

Thanks for the swift reply, but I amm very confused, I can't see anything I am missing in that example and what the code above.. Other than 

 

EXTI10_Wakeup_Enable

 

but that doesn't actually seem to have any implementation behind it?

Try to make UART receive work before implementing the stop and waking up mode.

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.
Saket_Om

Apologies, just to be clear, receive and transmit do work.

 

I can do a simple ping/pong when the chip is awake. What I can't do is a get the board to wake up from sleep :(