2018-08-04 06:22 AM
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
2018-08-04 11:01 AM
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;
2018-08-04 11:30 AM
no elasticity means?
2018-08-04 12:06 PM
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.
2018-08-05 12:50 AM
How can I do it the best way using a buffer in between and not disturbing any of my tasks running in FreeRTOS?
2018-08-05 03:34 AM
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.
2018-08-05 05:20 AM
>>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.