DMA interrupts #9656
Replies: 2 comments 1 reply
-
Thank you. Note that with the above mentioned dma class you do not have to ping pong. With A workaround would be a timer or async sleep that resumes activity just in time to wait say the last 5% of transfer time to finish by I agree that polling is an undesirable solution. Perhaps a minimal polling is viable like waiting/sleeping a crude estimate of 75% the single array transfer time, then checking actual transfer count, computing the error and waiting/sleeping for a better estimated rest of time. I plan to extend my class to include transfers of ADC, I2C and SPI and then checking if the same API may be applied for other hardware like the pyboard. I had the impression that agreement on a certain API was one of the stumbling blocks of getting a universal dma functionality in uPy. |
Beta Was this translation helpful? Give feedback.
-
With a new member function
of the dma class and
in the end of rp2_dma_test5.py I get
So the interrupts are there. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to set up a DMA transfer between memory and some external peripheral on a RP2 (Pico).
I want to use one DMA channel and ping-pong between two memory buffers of fixed length so that while one is being transferred to the peripheral (e.g. PWM or PIO) via DMA, the other is available for signal processing or updating. The DMA cycle time is controlled by a timer (sample rate of audio).
To do this, I need an interrupt after the buffer has been transferred to tell me when to the DMA to change the source address to the other buffer that is finished being processed. So the two data buffers "ping-pong"-- whilst one is being transferred, the other is available for processing.
I can do this easily in C and it works very well (like the example on page 99 of the RP2040 data sheet). Is there a way to set up a DMA-transfer complete interrupt handler in MicroPython? I suppose I could manually program the peripherals and the NVIC registers but was wondering if there was an alternative. I did review https://github.com/rkompass/RPi2040_mPy/tree/main/rp2_dma excellent DMA helper utilities and that is a good start.
Note that I can use a second DMA to set up a ping pong scheme and it may be faster, but I still need an interrupt to know when one of the channels is idle so I know when to update the buffer (I don't want to poll).
Beta Was this translation helpful? Give feedback.
All reactions