G4Zeal
G4Zeal

Reputation: 11

How to receive more data (greater than, >128) at once on ESP32 UART Rx PORT?

I am Unable to receive more data, Only half of data is received on UART Port. What can I do to get full data ?

I tried changing H/W FIFo (in uart.h, espressif files) to full data length (256) from 128. It did not worked.

switch(event.type)
{   
    case UART_DATA: 

    ESP_LOGI(TAG, "Event DATA SIZE [UART DATA]: %d", event.size);                                   
    uart_read_bytes(UART_NUM_2, UART_event_data, event.size, portMAX_DELAY); 
    printf("Received data from QR Code is ........... %s\n", UART_event_data);
    break;
}

Expected Incoming data is of full length 256 B.

Upvotes: 1

Views: 5457

Answers (3)

G4Zeal
G4Zeal

Reputation: 11

Finally, I am going with reading single byte till the string (expected data) ends. byte by byte.

Upvotes: 0

rustyx
rustyx

Reputation: 85316

Create a proper ISR and mark it IRAM_ATTR so that it's always in the cache.

In the ISR, copy the data from uart_read_bytes into a queue (xQueueSendFromISR) and don't do any other work, to keep the ISR small and fast.

Definitely don't call printf or log from an ISR. Create another (user) task and call xQueueReceive in a loop there, where you can print the data and do any other work.

Upvotes: 0

Christian B.
Christian B.

Reputation: 814

From https://www.esp32.com/viewtopic.php?t=8858 : "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."

Furthermore the author states that changing the size is not trivial. Long story short: your best bet is mostlikely to work around this limitation by collecting the message from the FIFO in parts and put them in another buffer together. Alternatively you can hope that they implemented a way to change the FIFO length by now. Further research in the esp forum/doc might help.

Upvotes: 1

Related Questions