DMA "blink" #12202
-
Hi, A bit of a silly question. To learn about how to implement DMA in upython. I want to make a code that would switch On a GPIO using DMA. Then activate another DMA channel to switch it Off, to kind of blink, once. I read and followed tutorial on uctypes (https://www.youtube.com/watch?v=WWby6nWORaQ) and on DMA (https://people.ece.cornell.edu/land/courses/ece4760/RP2040/index_rp2040_Micropython.html , plus some example found here and on the past forum). This is what I did and where I reached so far (at the end, I will add the full code to simplify copy-paste).
So far so good, then to check if the addresses and the value that I am writing to the gpio0 control register are correct I did:
Now I would like to create and activate a DMA channels that writes to the gpio0 control register (located at mem32[1073823748]) the value 13061.
I define the DMA channel using the following code, I found this code online, but I could have re-write it using uctypes.
Then I set the DMA write and read register and the transfer counter. Then I start the DMA.
I was expecting the gpio0 to turn ON but nothing happens. I think the error might lays on how I tell the DMA to which address to write to. I might need to define it in another way (maybe using uctypes pointer?). Cheers,
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
You might want to have a look at my unfinished DMA class, as it seems you are programming for the RP2040. As far as I can see the src and dst addresses are correct. In principle your example should work. |
Beta Was this translation helpful? Give feedback.
-
Hello, Thank you for the lead! I re-wrote the code (using also uctypes for the DMA) and now it works like a charm. I attach the full code here below:
|
Beta Was this translation helpful? Give feedback.
-
I found this rp2040 DMA library and samples to be very helpful |
Beta Was this translation helpful? Give feedback.
I have to correct myself:
seems correct, but
indeed is wrong, as you setup the DMA to write into that array then. so that it becomes
array("I",[13061])
.Instead
dst = 1073823748
would be correct here.