Page 1 of 1

UART TX exact timing

Posted: Fri Aug 19, 2022 2:31 pm
by kaspernyhus
Hi,

Is it possible to control the exact timing of a UART transmit?

I'm looking to do the following:
- Transmit one byte over UART eg. 0x35
- Wait 25ms
- Transmit the same byte again eg. 0x35

The result of

Code: Select all

uint8_t data = 0x35;
uart_write_bytes(uart_num, &data, sizeof(data));
vTaskDelay(pdMS_TO_TICKS(25));
uart_write_bytes(uart_num, &data, sizeof(data));
is the two bytes send right after each other. Changing the delay to 50 makes the wait time somewhat variable either 16ms or 24ms.

I suspect that the exact timing of the UART peripheral is outside our control? Or?

Thanks,
Kasper Nyhus

Re: UART TX exact timing

Posted: Sat Aug 20, 2022 2:43 am
by ESP_Sprite
Perhaps try calling uart_wait_tx_done() after sending the bytes.

Re: UART TX exact timing

Posted: Sun Aug 21, 2022 1:03 pm
by kaspernyhus
that absolutely improved the timing!

thanks once again ESP_Sprite