Quantcast
Viewing all articles
Browse latest Browse all 4833

General • [SOLVED] UPDATED Pico tinyUSB Audio and MIDI - ADC DMA capture

I think there is a problem with your DMA chaining. There's two ways to get one DMA channel to start another - the "chain-to" which you are using, and the "trigger alias register". I've seen people use both at once (including myself when first trying it!), and that definitely doesn't work usefully. Using chain-to when you are writing registers in the same DMA channel seems like it out to work but has a timing hazard - which is going to happen first, the write to dma_hw->ch[sample_chan].write_addr, or the start of the next transfer (caused by the chain-to)? Given that there's a lot of pipelining in the DMA and memory system, those can easily occur in the wrong order, giving the sort of hiccough you are observing.

The fix:

1) Turn off chain-to on your second DMA (you still need it on the first one)

2) use dma_hw->ch[sample_chan].al2_write_addr_trig instead of dma_hw->ch[sample_chan].write_addr.
Sorry for the delay and thank you for the response - I tried a few combinations of what you suggested but never got it to work. So I went back to the drawing board. I found a new example at: https://www.hackster.io/sandeep-mistry ... ico-cc9bd5

the only problem is that the example above is designed for a PDM microphone. There is an analog example, but it only prints values to serial. After combining some things I learned from other ADC DMA examples I was ultimately successful in getting the ADC to stream over USB by replacing the PDM components with Analog (ADC) microphone calls. This was straight forward, but some changes needed to be made:

- Change the CMAKE file to have it point to the analog_microphone library instead of the PDM library
- The bias was disabled
- in analog_microphone.c on line 197 the code was changed to mask, shift, and scale the data coming from the DMA so it would match the USB data type:

Code:

    for (int i = 0; i < samples; i++) {        *out++ = ((*in++ & 0xFFF) - 2048)*64;    }
The forked version of the library can be found here:
https://github.com/mdhosale/microphone ... ugh-midiIO

I am not planning to support this code but post it in case it is helpful to anyone.

Statistics: Posted by mfromage — Mon Aug 19, 2024 9:20 pm



Viewing all articles
Browse latest Browse all 4833

Trending Articles