Running into issues outputting audio to Adafruit feather rp2040 #2587
-
I am running into issues getting an audio output to a speaker connected to an Adafruit prop-maker feather rp2040. I have my code below that I flashed to the microcontroller, I get confirmation that the audio data is being received but no audio is played and I am unsure if I am outputting correctly.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You should try one of the I2S output examples to verify the pins. If the examples don't work then the pins you're using may not be right, or maybe the I2S DAC needs some kind of control to actually turn on (i.e. does it need an I2C write or GPIO pin set high?). I'm not sure the USB CDC buffer can actually grow to 128 bytes so your loop may never actually read anything. We don't use a separate FIFO since it would just be wasted memory copies. So, try 16 or 32 bytes instead of 128 in your buffer read/write size. Also, while 44.1Khz, 16b, stereo only requires ~1.4Mbit and USB 1.1 theoretically gives 12Mbit, I think you're not actually going to be able to reach that rate using a normal CDC(Serial) interface. To get high rates I believe isochronous channels need to be set up (like a USB audio card) to guarantee bandwidth and latency. That's beyond the scope of this core. You may want to consider only doing mono (and duplicating samples in the code), or 16Khz (and changing the I2s frequency), or even 8-bit writes (rehydrate to 16b in code). No matter what you do, you'll probably want to increase the i2s buffer size to help avoid underflow once things get started. This is in the examples as well. |
Beta Was this translation helpful? Give feedback.
You should try one of the I2S output examples to verify the pins. If the examples don't work then the pins you're using may not be right, or maybe the I2S DAC needs some kind of control to actually turn on (i.e. does it need an I2C write or GPIO pin set high?).
I'm not sure the USB CDC buffer can actually grow to 128 bytes so your loop may never actually read anything. We don't use a separate FIFO since it would just be wasted memory copies. So, try 16 or 32 bytes instead of 128 in your buffer read/write size.
Also, while 44.1Khz, 16b, stereo only requires ~1.4Mbit and USB 1.1 theoretically gives 12Mbit, I think you're not actually going to be able to reach that rate using a normal CDC(Se…