cancel
Showing results for 
Search instead for 
Did you mean: 

how to receive DMA from multiple UART

HZaib.1
Associate III

Hi, I am a newbie in stm32. I am trying to receive DMA from USART1,USART2,USART3.

But I am confused as how to do it because, all of them go inside same routine of DMA. Therefore how do I distinguish between different usart.

my controller is stm32f103c8

1 ACCEPTED SOLUTION

Accepted Solutions

Are you talking about Cube/HAL?

And you want to distinguish UARTs in the callbacks? You should probably go something like

if (husart->Instance == USART1) {

// handle USART1

} else if { // etc.

I don't use Cube.

Of course, this is inefficient and clumsy, but that's Cube/HAL for you. Cube/HAL is intended for "usual" application, which you can click easily in CubeMX and then it works "out of the box"; anything beyond that is usually more cumbersome than if you'd write it normally.

JW

View solution in original post

2 REPLIES 2

Are you talking about Cube/HAL?

And you want to distinguish UARTs in the callbacks? You should probably go something like

if (husart->Instance == USART1) {

// handle USART1

} else if { // etc.

I don't use Cube.

Of course, this is inefficient and clumsy, but that's Cube/HAL for you. Cube/HAL is intended for "usual" application, which you can click easily in CubeMX and then it works "out of the box"; anything beyond that is usually more cumbersome than if you'd write it normally.

JW

thanks.

Yes this is what I was actually looking for. thank you.

I am actually really liking HAL. but it is true there are some shortcomings which u have to work around. I have wrote some of the drivers for uart myself but only till interrupt not for dma and now I am so far beyond into my project that I cant discard HAL XD