cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4xx + UART1 DMA + UART2

yoann LBY
Senior
Posted on August 04, 2017 at 15:16

hi,

i have STM32F401 with uart1 configurate in DMA and i would like to add uart2 (in DMA or not)

is it possible to do it?

how i manage the IT flag?

UART1 DMA, call fct :

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandleArg)

{

  WiFi_HAL_UART_TxCpltCallback(UartHandleArg);

}

but when interrupt is uart2, how i do?

thks

Yoann 

6 REPLIES 6
Posted on August 04, 2017 at 17:05

Have a unique callback for each U(S)ART, or recognize which one is being discussed by looking at the passed in handle.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
yoann LBY
Senior
Posted on August 04, 2017 at 17:36

what function i call to recognize which one is being...?

Posted on August 04, 2017 at 18:13

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)

{

if (huart->Instance == USART1) // change USART instance

{

// Handle/Dispatch USART1 Stuff Here

}

}
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
yoann LBY
Senior
Posted on August 08, 2017 at 08:56

hi,

of course!

i will check

thks

yoann

yoann LBY
Senior
Posted on August 31, 2017 at 11:21

hi,

next of the topic,

i configure uart1 dma rx et uart2 it rx

uart1 work ok but uart2 Rx receive ONLY 1 char and not good size

example : uart2 must receive XR+S.BND=1 and in buffer i receive only X.

Program not enter in HAL_UART_RxCpltCallback because variable Message_push_ready always equal to RESET.

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)

{

  if (UartHandle->Instance == WB_WIFI_UART) //USART1

 {

  /* Disable the Idle Interrupt */

     __HAL_UART_DISABLE_IT(UartHandle, UART_IT_IDLE);   

    Read_DMA_Buffer();   

    /* Enable the Idle Interrupt */

    __HAL_UART_ENABLE_IT(UartHandle, UART_IT_IDLE);

 }

  else if (UartHandle->Instance == STM32_UART_MSG)  //USART2

  {

    Message_push_ready = SET;  

    STM32_MSG_HAL_UART_RxCpltCallback(UartHandle); 

  }  

}

an idea why i receive only 1 char?

is it better to setup uart2 with DMA two?

how i can do that?

Thks

yoann

yoann LBY
Senior
Posted on October 09, 2017 at 10:05

hi,

fixed, i didn't understand how works idle callback

see

https://community.st.com/0D50X00009Xkg8YSAR

.

thks

Yoann