DMA example for UART communication for ESP32

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

DMA example for UART communication for ESP32

Postby Ritesh » Thu Feb 15, 2018 4:53 pm

Hi,

We are working on ESP32 board and also using ESP32 IDF for application development as per our project Requirement.

Right now, we had connected two different RF module over UART in which sometimes both modules are sending 128 bytes packets at interval of 100 milliseconds. Here, we are using interrupt based communication to get data from UART as per provided into example.

So, at every one byte, we are getting interrupt which creates Task Watchdog Timeout after some interval because of not feeding of Watchdog Time. As both tasks to get data from different UART are too much busy or we can say in blocking state.

So, we are now thinking to use DMA for that to become communication faster. We already had started to look User Manual of ESP32 for DMA and found some information but not found any example for that.

So, Does anyone has implemented UART based communication using DMA? If yes then please provide sample example or link for that.
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DMA example for UART communication for ESP32

Postby Ritesh » Fri Feb 16, 2018 3:53 am

Hi Loboris or Espressif Systems Developer,

Do you have any idea or any base examples for how to use DMA for UART into ESP32?

Please let me know reference link or any example based on that ASAP.
Regards,
Ritesh Prajapati

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: DMA example for UART communication for ESP32

Postby loboris » Fri Feb 16, 2018 3:02 pm

I don't think there is any need to use DMA with UART with your usage case.

I'm only using the uart event task, similar to esp-idf/examples/peripherals/uart_events example.
I've newer had any problems with it and response time is quite fast.
At 128 byte packets every 100 ms you should have no problem, I've tested it with much longer packets and much shorter intervals.

I only have an example in my MicroPython port, the source is here.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: DMA example for UART communication for ESP32

Postby WiFive » Fri Feb 16, 2018 5:22 pm

The problem is setting fifo threshold to 1 byte

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DMA example for UART communication for ESP32

Postby Ritesh » Fri Feb 16, 2018 6:48 pm

loboris wrote:I don't think there is any need to use DMA with UART with your usage case.

I'm only using the uart event task, similar to esp-idf/examples/peripherals/uart_events example.
I've newer had any problems with it and response time is quite fast.
At 128 byte packets every 100 ms you should have no problem, I've tested it with much longer packets and much shorter intervals.

I only have an example in my MicroPython port, the source is here.
Hi, We are developing application and we are using so many tasks in our application.

So, We are using interrupt based UART task to receive data from your continuously with 1 byte interrupt.

Also, We are validating received frame and sent it to cloud with proper packet encoding.

Also we had connected 2 different RF module over 2 UART which sending data continuesly 100 msec of interval.

Let me know if you need any other information regarding this
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DMA example for UART communication for ESP32

Postby Ritesh » Fri Feb 16, 2018 6:54 pm

WiFive wrote:The problem is setting fifo threshold to 1 byte
We didn't set fifo threshold to 1 byte but set 1 byte as interrupt to get each byte interrupt.

So, will it create any problem while receiving data from both UART at every 100 msec?

Let me know if you had any idea regarding DMA UART example or any information regarding that.
Regards,
Ritesh Prajapati

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: DMA example for UART communication for ESP32

Postby WiFive » Fri Feb 16, 2018 10:20 pm

Ritesh wrote:
We didn't set fifo threshold to 1 byte but set 1 byte as interrupt to get each byte interrupt.
Isn't that the same thing?

Code: Select all

uint8_t rxfifo_full_thresh
UART RX full interrupt threshold.
Why do you need an interrupt for each byte? Default is 120.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DMA example for UART communication for ESP32

Postby Ritesh » Sat Feb 17, 2018 4:46 am

WiFive wrote:
Ritesh wrote:
We didn't set fifo threshold to 1 byte but set 1 byte as interrupt to get each byte interrupt.
Isn't that the same thing?

Code: Select all

uint8_t rxfifo_full_thresh
UART RX full interrupt threshold.
Why do you need an interrupt for each byte? Default is 120.
We don't have fixed size of frame coming from UART module to ESP32. Right now, we are testing with fixed length of frame but in real communication it is not fixed as that will be variable.

That is why we had kept interrupt for one byte to serve lowest to lowest frame of one byte as well.

So, what you suggest to do in this type of variable frame communication in fast interval like 100 msec?
Regards,
Ritesh Prajapati

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: DMA example for UART communication for ESP32

Postby WiFive » Sat Feb 17, 2018 5:02 am

End of frame will also generate tout interrupt so unless you need ultra realtime processing of messages it should be ok.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: DMA example for UART communication for ESP32

Postby Ritesh » Sat Feb 17, 2018 9:44 am

WiFive wrote:End of frame will also generate tout interrupt so unless you need ultra realtime processing of messages it should be ok.
Let's consider our UART module is going to send packets with variable size in every 100 msec of interval over Interrupt and also it needs some little bit time to process that packet then how we can handle that type of situation using tout Interrupt?

Would you please give me example for that?
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 107 guests