[closed] How to use DMA in earl's core together with PWM #1050
-
Hi Earl, I'd like to use DMA for PWM control, based on a great idea from BirchJD. I tried to port it to your Arduino core with this code (link) and I failed. A simple "copy&paste" does not work. It produces no sound in compare to the pure c-based PoC code. The main code to be ported is just a few lines in the file WavPwmAudio.cpp - same for both versions: sdk and arduino code. I think I have read that Arduino uses some PWM channels, so we are not free to use all of them. Before I will spend Xmas on reading, I would like to ask for your opinion and or support. Do you see a method to port the code? This allows to add something more than beeps to the arduino pico projects, without any (almost) additional hardware. Cheers and thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 17 replies
-
Unfortunately the links in your post don't seem to work. All seem 404'd. Anyway, this is something I was thinking about myself but never got around to doing. The idea is to set up a high frequency PWM signal on a pin and then use the DMA engine, on a timed transfer to send samples to it. There are no PWM units used in the core unless you do I would start with the I2S library and the AudioRingBuffer. You'll need to config the DMA to use a timer, not a FIFO free signal. DMA target will be the PWM value reg for the associated pin, not the PIO FIFO. The PWM channel will need to be config'd at the beginning and the audio samples received from the app will probably need to be scaled to the max PWM count. It shouldn't be rocket science, but it probably is a good afternoon's hacking. :) |
Beta Was this translation helpful? Give feedback.
-
Check #1076, @petervflocke . I spent a couple afternoons adapting the I2S to PWM and it works pretty nicely IMHO! |
Beta Was this translation helpful? Give feedback.
Check #1076, @petervflocke . I spent a couple afternoons adapting the I2S to PWM and it works pretty nicely IMHO!