cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to bypass two UARTs without disturbing any other tasks running on STM32 on freeRTOS

Abhishek Kumar
Associate III

I have an application running on STM32F777 mcu running on FreeRTOS hosting around some 7 tasks at equal priorities. I want to bypass (pass-through) two UARTs on the mcu in full duplex mode. Can you please help me suggest the best way to do so if:

1.) I do want to maintain a buffer in between of the two UARTs

2.) I do not want to maintain any buffer in between of the two UARTs

6 REPLIES 6

Without a buffer you have no elasticity, but you could do something like

if (USARTA.RXNE)

USARTB->RDR = USARTA->RDR;

if (USARTB.RXNE)

USARTA->RDR = USARTB->RDR;

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

no elasticity means?

Ebb and flow of data at roughly the same speeds, but not exactly, and not arriving/departing at the same time.

Like a rubber band expanding/contracting, accommodating variation in a system that is asynchronous, not synchronous end-to-end.

0690X0000060RTgQAM.jpg

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

How can I do it the best way using a buffer in between and not disturbing any of my tasks running in FreeRTOS?

Alan Chambers
Associate II

Two circular TX buffers ought to do it. On RXNE interrupt, stuff the value into the TX buffer of the other USART and enable that USART's TXE. On TXE interrupt, stuff the next value from the TX buffer into DR. Disable TXE when the buffer is empty. Or something like that.

I'd be interested in a DMA solution for this to reduce interrupts. Perhaps a pool of small buffers which are each first used for RX, then queued for TX (on TC), and then returned to the pool (on TC). This will add some latency to the bridge, and you might want to handle the RX idle condition.

>>How can I do it the best way using a buffer in between and not disturbing any of my tasks running in FreeRTOS?

Disturb them how? Some code is going to have to manage the USARTs, its not going to happen magically. You want to code something that is simple and efficient, and doesn't block waiting for resources.

The IRQ Handlers for the USART don't have to cause a task switch, they can be self contained and separate/independent from the RTOS.

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