cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 uart receiving + dma standard mode in stop 1

deeky
Associate

With a STM32u5 controller I'm trying to reach stop1 while still receiving incoming uart data and putting the data memory with DMA. I use LPUART1 and GPDMA1 with the receiving side configured to receive a interrupt on bus idle (RTO) and the DMA is used in standard request mode. These should work in stop1 when the clocks are enabled. Without going to stop mode the code works. When I go to stop1 mode and receive data I will wake up on a overrun error meaning that (I think) that DMA is not working since it is not getting the bytes from the uart peripheral causing the overflow error to hit. 

My initiation code looks like this:

    HAL_Init();
    init_clock_and_power();
    MX_ICACHE_Init();
    MX_GPDMA1_Init();
    MX_GPIO_Init();
    MX_LPUART1_UART_Init();

    __HAL_RCC_LPUART1_CLKAM_ENABLE();
    __HAL_RCC_LPUART1_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPDMA1_CLK_SLEEP_ENABLE();
    __HAL_RCC_AHB1_CLK_ENABLE();

    UART_WakeUpTypeDef wakeup_config;
    wakeup_config.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
    HAL_StatusTypeDef res2 = HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, wakeup_config);

    __HAL_LOCK(&hlpuart1);
    ATOMIC_SET_BIT(hlpuart1.Instance->CR1, USART_CR1_UESM);
    ATOMIC_SET_BIT(hlpuart1.Instance->CR1, USART_CR1_RTOIE);
    ATOMIC_SET_BIT(hlpuart1.Instance->CR1, USART_CR1_IDLEIE);
    ATOMIC_SET_BIT(hlpuart1.Instance->CR1, USART_CR1_RE);
    ATOMIC_SET_BIT(hlpuart1.Instance->CR1, USART_CR1_UE);
    __HAL_UNLOCK(&hlpuart1);

I use the following call for receiving data:

HAL_UARTEx_ReceiveToIdle_DMA(handle->uart, handle->rx_buffer, handle->rx_buffer_size);


Has someone a idea what I'm missing to enable the GPDMA or what is going wrong?

1 REPLY 1
Sarra.S
ST Employee

Hello @deeky

Could you refer to this article for GPDMA configuration: How to configure the GPDMA - STMicroelectronics Community

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.