2022-05-20 01:21 AM
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
Solved! Go to Solution.
2022-05-20 02:48 AM
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
2022-05-20 02:48 AM
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
2022-05-20 02:52 AM
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