Can't change size of UART TX FIFO, ESP32m esp-idf

Wowebex
Posts: 2
Joined: Wed Jan 16, 2019 2:15 pm

Can't change size of UART TX FIFO, ESP32m esp-idf

Postby Wowebex » Wed Jan 16, 2019 3:02 pm

Hi!
I'm trying to change the size of UART0's TX FIFO o 512 Bytes.

The FIFO's size (in byte) can be set in UART_MEM_CONF_REG configuring bits 7 to bit 10. (ESP32 TRM V4.0, page 364)
This register is 0x88 by default: 128 Byte TX FIFO and 128 byte RX FIFO. So bit 7 = 1 sets 128 Byte TX FIFO size.

Unfortunately there is no info how to set Bits 7, 8,9, and 10 to change the FIFO size. My first idea was to set bit 8 for 256 bytes size, bit 9 for 512 bytes and bit 10 to 1024 bytes. I intend to use UART0 only, so there's no problem with the other UART's FIFO size.

I tried the following lines:

Code: Select all

// Create a byte pattern to send
char buffer[256];
for (int i = 0; i < 256; i++) buffer[i] = i;

// f.e.set bit 8 for (maybe??) 256 bytes TX FIFO size, other configurations has been tested as well
WRITE_PERI_REG(UART_MEM_CONF_REG(uart_num),0x108);
    
// Start uart driver, no event queue, no TX ringbuffer
uart_driver_install(uart_num, UART_BUF_SIZE, 0, 0, NULL, 0);
   
// send 256 bytes from a buffer
uart_tx_chars(uart_num, (const char*)buffer, 256);
That's not working. The transmission ends after 128 bytes are sent out. No matter how I set the bits 7 to 10 in the UART_MEM_CONF_REG - always 128 bytes are sent.

What's wrong, what did I miss?

Thanks, Wolf

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

Re: Can't change size of UART TX FIFO, ESP32m esp-idf

Postby ESP_Sprite » Thu Jan 17, 2019 1:17 am

Seems the UART driver assumes the UART FIFO always is 128 bytes (compile-time defined as UART_FIFO_LEN). You can maybe work around this by copying the relevant bits of uart_fill_fifo to send your data manually:

Code: Select all

    for (i = 0; i < copy_cnt; i++) {
        WRITE_PERI_REG(UART_FIFO_AHB_REG(uart_num), buffer[i]);
    }

Huub Joosten
Posts: 1
Joined: Thu Jan 17, 2019 10:16 am

Re: Can't change size of UART TX FIFO, ESP32m esp-idf

Postby Huub Joosten » Thu Jan 17, 2019 1:11 pm

I have the same question

Wowebex
Posts: 2
Joined: Wed Jan 16, 2019 2:15 pm

Re: Can't change size of UART TX FIFO, ESP32m esp-idf

Postby Wowebex » Fri Jan 18, 2019 8:22 am

Thank you ESP_Sprite - I'll give it a try and report back!

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

Re: Can't change size of UART TX FIFO, ESP32m esp-idf

Postby ESP_Sprite » Sat Jan 19, 2019 3:38 am

Also, if you need this in the actual driver, don't hesitate to put a feature request up on the ESP-IDF github, so we know there's demand for this.

MateusGL
Posts: 17
Joined: Sun Feb 23, 2020 5:18 am

Re: Can't change size of UART TX FIFO, ESP32m esp-idf

Postby MateusGL » Wed May 04, 2022 7:14 pm

This post is old, but maybe it can be helpful to someone...

uart_tx_chars() writes directly to the UART fifo, which is limited to 128 bytes.

You need to use uart_write_bytes(), that overcomes this hardware limitation. Using this function, the length of the message is limited by the size that you specified when you installed the driver.

Who is online

Users browsing this forum: No registered users and 65 guests