uartSendTimeout - transmission problem Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

uartSendTimeout - transmission problem

Post by vrollei »

Hi,

there is some strange problem with sequential calls of uartSendTimeout: 3 calls of uartSendTimeout sequentially, last call will send 0xFF instead of real data, if use debugger and step over 3 calls each sends correct data.
ChibiOS 17.6 and STM32L011x4

ps.
What is the difference between uartSendTimeout and uartSendFullTimeout, uartSendFullTimeout sends successfully data and constantly returns TIMEOUT
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: uartSendTimeout - transmission problem

Post by Giovanni »

Hi,

uartSendFullTimeout() waits for the data to be entirely sent, uartSendTimeout() just waits for data to be placed in the data register but transmission is still ongoing.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: uartSendTimeout - transmission problem

Post by vrollei »

Hi,

thanks for reply!

Addition note: ChibiOS NIL 17.6.

Is it necessary to wait something after call uartSendTimeout and returning for it with result MSG_OK and number of frames equals to value passed to uartSendTimeout?

Is there any reason why uartSendFullTimeout can send successfuly data over UART and returns MSG_TIMEOUT?

Test case:

1. Sending 3 bytes using uartSendTimeout, result MSG_OK, *np == 3, Logic Analyser result: ok
2. Sending 12 bytes using uartSendTimeout, result MSG_OK, *np == 12, Logic Analyser result: ok
3. Sending 2 bytes using uartSendTimeout, result MSG_OK, *np == 2, Logic Analyser result: one byte 0xFF
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: uartSendTimeout - transmission problem

Post by Giovanni »

Hi,

The function should never return MSG_TIMEOUT unless there is some HW handshake enabled that can slow down transmission. Moving this topic in "bug reports" or it would get lost and forgotten.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: uartSendTimeout - transmission problem

Post by vrollei »

Hi,

UART config:

UARTConfig portUartConfig = { .txend1_cb = NULL,
.txend2_cb = NULL,
.rxend_cb = NULL,
.rxchar_cb = NULL,
.rxerr_cb = NULL,
.timeout_cb = NULL,
.timeout = 0,
.speed = 9600,
.cr1 = 0,
.cr2 = 0,
.cr3 = 0
};
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: uartSendTimeout - transmission problem

Post by vrollei »

Hi,

this test case works fine (HW view) except MSG_TIMEOUT in 3d step:

1. Sending 3 bytes using uartSendTimeout, result MSG_OK, *np == 3, Logic Analyser result: ok
2. Sending 12 bytes using uartSendTimeout, result MSG_OK, *np == 12, Logic Analyser result: ok
3. Sending 2 bytes using uartSendFullTimeout, result MSG_TIMEOUT, *np == 2, Logic Analyser result: ok
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: uartSendTimeout - transmission problem

Post by Giovanni »

What is the timeout you specified in uartSendTimeout()?

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: uartSendTimeout - transmission problem

Post by vrollei »

Now it is 300ms, it was 2000ms with the same result

uartSendTimeout(sprodp->uartDriver, &n, message->buf, MS2ST(300))

I tried to add threadSleep (10 - 20ms) between step 2 and 3 but it did not help.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: uartSendTimeout - transmission problem

Post by Giovanni »

It looks like the DMA stops sending data to the UART so the function is blocked until the timeout happens (the caller thread is woken by a DMA IRQ or timeout).

Do you have other drivers using DMA active? I would also try it on a different model of STM32, just in case...

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: uartSendTimeout - transmission problem

Post by vrollei »

Only PAL and UART drivers are active.
Post Reply