I'm looking for information on programming the DMA controller on the ESP32 (beyond what is in the Tech. Ref.). Specifically I want to understand how to trigger a DMA burst using a GPIO (not mediated using an interrupt on the CPU).
The scenario is this: I have an SPI connected ADC. The ADC provides a pin that signals a conversion is ready. Every time that happens I want the SPI to read from the ADC and DMA to transfer the read data into a circular buffer. It seems like that it is possible to make a circular buffer using a circular dma config linked list with a single entry. But where do I configure a trigger? Is this even possible with ESP32?
Regards,
Felix
How to trigger DMA from external input
-
- Posts: 9040
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to trigger DMA from external input
You can't on current ESP chips, you'll need to have an interrupt on that GPIO that manually triggers the SPI transfer.
-
- Posts: 124
- Joined: Fri May 24, 2019 2:02 am
Re: How to trigger DMA from external input
Thanks for that. It is as I suspected. Now I have a problem.ESP_Sprite wrote: ↑Fri May 13, 2022 1:40 amYou can't on current ESP chips, you'll need to have an interrupt on that GPIO that manually triggers the SPI transfer.
I need to read 8bytes from ADC over SPI when an interrupt fires every ~60uS. This is too fast to get a freertos task to do the read with a task notify fired from the interrupt. But I can not do SPI read from the interrupt itself. How would this be done on ESP32?
I could poll the ADC on the SPI until I get the valid data. But this seems wasteful and I have a lot to fit into this firmware...
-
- Posts: 124
- Joined: Fri May 24, 2019 2:02 am
Re: How to trigger DMA from external input
Is it possible to start a DMA SPI transaction from a gpio interrupt and then handle the transaction finished interrupt to copy the data to a buffer?
-
- Posts: 124
- Joined: Fri May 24, 2019 2:02 am
Re: How to trigger DMA from external input
Looking at the code in spi_device_queue_trans() It looks like I could duplicate that and use xQueueSendFromISR to make it ISR compatible. Any IDF developers care to comment?
-
- Posts: 124
- Joined: Fri May 24, 2019 2:02 am
Re: How to trigger DMA from external input
I tried that solution, queue spi transaction from isr. It knocks quite a bit of overhead off but there is still around 20uS of task switching and queue overhead.
Who is online
Users browsing this forum: No registered users and 133 guests