Skip to main content
Visitor II
May 17, 2024
Question

Trigger DMA of USART6 When Receive anything On Another USART in STM32H723VGT6

  • May 17, 2024
  • 1 reply
  • 1207 views

Hi,

"Could you guide me on configuring USART1 and USART6 on the STM32H723VGT6 microcontroller to enable data forwarding? Specifically, I'm looking to trigger USART6 DMA transmission whenever USART1 receives data on interrupt. How can I achieve this effectively, ensuring seamless data transfer between the two USART peripherals while optimizing performance?"

Aman Sharma

Regards.

    This topic has been closed for replies.

    1 reply

    Graduate II
    May 17, 2024

    Take a look at this example https://github.com/karlyamashita/Nucleo-G431RB_Three_UART/wiki

    It actually forwards 3 times using the 3 UART ports on a Nucleo board.

    20DeViL00Author
    Visitor II
    May 19, 2024

    Hi Karl 

    I wanted to discuss a refinement in the configuration regarding the USART DMA transfer setup you provided. Currently, the configuration appears to be configuring both the UARTs on DMA, which is not what I intend.

    My requirement is to have both UARTs operating via interrupts for receiving data. However, when a specific condition occurs, I want the data received on USART1 via interrupt in the RDR register to be immediately transferred to the USART6 TDR register using DMA, without interrupting the ongoing data reception process on both UARTs.

    To achieve this, I plan to enable DMA only for the transmission from USART1 to USART6 when the condition is met, while the interrupts will continue their work for receiving data as usual.

    Below is the current configuration of USART6 DMA for your reference:

    hdma_usart6_tx.Instance = DMA1_Stream1;
    hdma_usart6_tx.State = HAL_DMA_STATE_READY;
    hdma_usart6_tx.Init.Request = DMA_REQUEST_USART6_TX;
    hdma_usart6_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
    hdma_usart6_tx.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_usart6_tx.Init.MemInc = DMA_MINC_ENABLE;
    hdma_usart6_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_usart6_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    hdma_usart6_tx.Init.Mode = DMA_NORMAL;
    hdma_usart6_tx.Init.Priority = DMA_PRIORITY_MEDIUM;
    hdma_usart6_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;

    if (HAL_DMA_Init(&hdma_usart6_tx) != HAL_OK) {
    Error_Handler();
    }

    __HAL_LINKDMA(huart,hdmatx,hdma_usart6_tx);

    /* USART6 interrupt Init */
    HAL_NVIC_SetPriority(USART6_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(USART6_IRQn);

    And enabling the DMA in the USART1_IRQHandler.

    RcvIn = (unsigned short)(USART1->RDR & (unsigned short)0x01FF);
     if(RcvIn != NULL)
     if(HAL_UART_Transmit_DMA(&huart6,(uint8_t*)(USART1->RDR & (unsigned short)0x01FF),1) != HAL_OK)
     Error_Handler();

    However this Configuration is not working.

    Could you please guide me on how to modify this configuration to achieve the desired functionality? Your expertise and advice on this matter would be greatly appreciated.

    Looking forward to hearing from you soon.

    Warm regards,

    Aman Sharma.