Hi Kevin, I think it is possible to create a generic audio using PWM and DMA, but it will require two halves design (like many drivers in NuttX).
The top half will implement the high end driver to be present like an audio codec to the application (this way we don't need to modify existing applications), and the bottom half will be responsible for setting up the DMA channel to use with the PWM. Create a board only solution like you are thinking will work for your board, but if in the future you move to another arch you will need to reimplement it again and probably the way you are going to implement it the existing applications cannot be used. Tiago, since you are the audio guy, what do you think? Is it possible to create the "fake" audio codec that works with PWM and DMA the way I'm suggesting? BR, Alan On Sun, Feb 23, 2025 at 6:59 AM Kevin Witteveen <kevinwit1...@gmail.com> wrote: > Well that's unfortunate. It feels that this kind of system will not fit in > this OS without a bit of hacking. > I think I will implement this at board logic. Use DMAC.h device and > directly use it on the PWM register addresses after initializing them the > proper way using the PWM.h device. > Maybe it's possible to add this as a source file to the common RP2040 board > directory for everyone to enjoy. > > About the I2S... yeah i think i will go for that next time. I am a little > stuck with what I have on my PCB right now. > > Op zo 23 feb. 2025 02:20 schreef Tomek CEDRO <to...@cedro.info>: > > > Many people think about this but no solid implementation so far.. have > > you consider I2S audio codec? > > Tomek > > > > > > On Sun, Feb 23, 2025 at 12:07 AM Kevin Witteveen <kevinwit1...@gmail.com > > > > wrote: > > > > > > Thanks, however I'm specifically looking for audio. For example, music, > > > samples, etc. A tone is not enough for what I'm looking for. > > > Or did I miss something and the audio_tone is actually more than just a > > > tone? > > > > > > Op za 22 feb 2025 om 22:05 schreef TimH <t...@jti.uk.com.invalid>: > > > > > > > CONFIG_AUDIO_TONE? > > > > > > > > Not sure if that’s exactly what you’re after but could be? > > > > > > > > > On 22 Feb 2025, at 17:12, Kevin Witteveen <kevinwit1...@gmail.com> > > > > wrote: > > > > > > > > > > Hi nuttx, > > > > > > > > > > I need an audio device that can generate sound using PWM on the > > RP2040. > > > > It > > > > > appears nothing already exists for this. > > > > > What would be a good way to implement this? > > > > > > > > > > My previous implementation outside NuttX was to use DMA to feed > > samples > > > > > into a PWM register. Relatively simple. > > > > > However, in NuttX i now need to combine the PWM implementation with > > the > > > > > DMAC implementation. This is where I'm not sure how to "connect > them > > > > > together" on a proper "nuttx" way. > > > > > Then also have it show up as an audio device. > > > > > > > > > > in case you wonder about the concept PWM audio. It is a common way > to > > > > > generate audio. It is how class-D amplifiers work. This is because > > the > > > > duty > > > > > cycle of PWM when filtered becomes an analog signal. A very cheap > > way to > > > > > implement audio in systems. > > > > > > > > > > Are there any examples of projects out there that did this with > > Nuttx? > > > > > Or are there any people that have an idea how to take this project > > on? > > > > > Where do i begin? Where would i implement this? Board? > Architecture? > > > > > > > > > > I would appreciate any help > > > > > > > > > > > > > > > > -- > > CeDeROM, SQ7MHZ, http://www.tomek.cedro.info > > >