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
uartSendTimeout - transmission problem Topic is solved
- 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
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
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
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
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
- 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
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
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
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
};
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
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
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
- 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
What is the timeout you specified in uartSendTimeout()?
Giovanni
Giovanni
Re: uartSendTimeout - transmission problem
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.
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.
- 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
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
Do you have other drivers using DMA active? I would also try it on a different model of STM32, just in case...
Giovanni