Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChibiOS: UARTDriver: EVT_TRANSMIT_END is never seen resulting in slow half duplex TX to RX switch #26908

Open
IamPete1 opened this issue Apr 28, 2024 · 0 comments
Labels

Comments

@IamPete1
Copy link
Member

I have been poking about in the UART driver trying to get RS485 driver enable pin working, in the end I was able to use the hardware support. I was not able to get it to function acceptably in software because I discovered the EVT_TRANSMIT_END event is never triggered. This event is also used for the switch from TX to RX for half duplex support.

This is where we wait for the event in the UART thread:

eventmask_t mask = chEvtWaitAnyTimeout(EVT_TRANSMIT_DATA_READY | EVT_TRANSMIT_END | EVT_TRANSMIT_UNBUFFERED, chTimeMS2I(1));

Because it never triggers we wait for the timeout resulting in upto 1ms of delay in switching from TX to RX.

The event is checked again here:

if (_tx_initialised && ((mask & EVT_TRANSMIT_DATA_READY) || need_tick || (hd_tx_active && (mask & EVT_TRANSMIT_END)))) {

This commit adds a simple check if the event has ever been seen and reports in the @SYS/uarts.txt: IamPete1@6e3f29f

I have tested on a CubeOrangePlus using a range of serial protocols with and without the half duplex serial option set, I always get 0 for TX_end:

UARTV1
SERIAL0 OTG1  TX =  100671 RX =    2454 TXBD= 40048 RXBD=   976 TX_end=0
SERIAL1 UART2 TX =     665 RX =       0 TXBD=   264 RXBD=     0 TX_end=0
SERIAL2 UART3 TX =     665 RX*=       0 TXBD=   264 RXBD=     0 TX_end=0
SERIAL3 UART4 TX =    2754 RX =       0 TXBD=  1095 RXBD=     0 TX_end=0
SERIAL4 UART8 TX =       0 RX*=       0 TXBD=     0 RXBD=     0 TX_end=0
SERIAL5 UART7 TX =    5314 RX*=     650 TXBD=  2114 RXBD=   258 TX_end=0
SERIAL6 OTG2  TX =       0 RX =       0 TXBD=     0 RXBD=     0 TX_end=0
IOMCU   UART6 TX*=  166646 RX*=  106694 TXBD= 66295 RXBD= 42445 TX_end=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant