Page 1 of 2

uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 9:26 am
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

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 1:24 pm
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

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 2:48 pm
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

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 4:16 pm
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

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 4:25 pm
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
};

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 5:00 pm
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

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 5:47 pm
by Giovanni
What is the timeout you specified in uartSendTimeout()?

Giovanni

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 6:17 pm
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.

Re: uartSendTimeout - transmission problem

Posted: Sat Oct 28, 2017 6:51 pm
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

Re: uartSendTimeout - transmission problem

Posted: Sun Oct 29, 2017 9:06 am
by vrollei
Only PAL and UART drivers are active.