cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, I'm a beginner in the STM32 world. I want to realize a full-duplex UART communication. I find only info to multiple threads based on RTOS. Is possible to realize multiple threads do not use RTOS? Best regards, LeoG

LeoG
Associate II

I use the STM32F303 Nucle-64 board and I use Keil uVision to programming.

I use HAL_UART_Transmit/Receive function and I haven't problems.

9 REPLIES 9

The HAL_UART_Transmit/Receive() functions block, preventing concurrent activity. You'd likely need to use the IT variants and manage a buffer in the callback routines. I've posted example where I've discarded the HAL function as I've found the model to be bulky and problematic, and doesn't fit my serial buffering methods.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Alan Chambers
Associate II

Don't use HAL. I really have no idea what ST were thinking when they wrote it. For UART I use a class which buffers writes and performs a series of TX DMA transfers until the buffer is empty. At the same time, it performs RX DMA transfers into a ring of small input buffers, and uses the idle detection to catch the tail end of incoming data. Seems to work. It is all interrupt-driven, though I use a scheduler to process RX buffers in thread mode. Using an RTOS is orthogonal to this.

LeoG
Associate II

Thanks for the answers!!:beaming_face_with_smiling_eyes:

The question becomes interesting ... Is there any useful material (papers, examples...) where I can learn to program without HAL functions?:grinning_face_with_sweat:

Not really. My own experience is that I did not like the HAL when it was created, so I ignored it. I had already written peripheral drivers based around the Standard Peripheral Library, and still use them on relevant hardware. For devices without SPL support, it has proved pretty simple to write my own hardware abstraction layer for the peripherals or specific registers that I care about, in terms of CMSIS. I imagine that over time all the SPL elements will be replaced with home-grown type safe interfaces.

Ok, thanks for everything.

Piranha
Chief II

Introduction to MCUs in general:

https://www.embeddedrelated.com/showarticle/453.php

STM32 USART RX handling:

https://github.com/MaJerle/STM32_USART_DMA_RX

Generic lock-free FIFO ring buffer:

https://github.com/MaJerle/ringbuff

> I really have no idea what ST were thinking when they wrote it.

There is a catch - You're assuming that they were thinking...

A new hashtag: "Keep calm and no use HAL function .... " :grinning_face_with_sweat:

Great !! Thanks :thumbs_up: !!