Skip to main content
LeoG
Associate
August 12, 2019
Question

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

  • August 12, 2019
  • 9 replies
  • 2444 views

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.

This topic has been closed for replies.

9 replies

Tesla DeLorean
Guru
August 12, 2019

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Alan Chambers
Associate III
August 12, 2019

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.

Piranha
Principal III
August 14, 2019

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

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

LeoG
LeoGAuthor
Associate
August 15, 2019

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

LeoG
LeoGAuthor
Associate
August 12, 2019

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:

Alan Chambers
Associate III
August 13, 2019

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.

LeoG
LeoGAuthor
Associate
August 13, 2019

Ok, thanks for everything.

Piranha
Principal III
August 14, 2019

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

LeoG
LeoGAuthor
Associate
August 15, 2019

Great !! Thanks :thumbs_up: !!