UART TX exact timing

kaspernyhus
Posts: 22
Joined: Tue Mar 01, 2022 7:38 am

UART TX exact timing

Postby kaspernyhus » Fri Aug 19, 2022 2:31 pm

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

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: UART TX exact timing

Postby ESP_Sprite » Sat Aug 20, 2022 2:43 am

Perhaps try calling uart_wait_tx_done() after sending the bytes.

kaspernyhus
Posts: 22
Joined: Tue Mar 01, 2022 7:38 am

Re: UART TX exact timing

Postby kaspernyhus » Sun Aug 21, 2022 1:03 pm

that absolutely improved the timing!

thanks once again ESP_Sprite

Who is online

Users browsing this forum: Google [Bot], RalphD and 60 guests