Remote mic RX with PCM output

I’m trying to get the remote_mic_rx_raw project modified such that I can output audio over PCM (I have the audio shield board with the Wolfson h/w codec on it) instead of the OD. The main issue I am running into is that the audio stream from the ASRC is mono and the PCM peripheral requires stereo (or at least 2 channel mono) data. I am able to get the boot audible test signal to work (by duplicating the data values in BufferOut so that there is a L and R data sample for each point of the sine wave), so I believe I basically have the hardware configured properly.

I’ve tried various hacks to get this to work, like changing the ASRC output DMA config to have the memory dest be 16 bit word size (assuming that then BufferOut would have the 16-bit audio spaced out every other 16-bits in memory). However nothing I have tried quite gets things to work correctly.

I am assuming that I need to take BufferOut and duplicate audio samples into another buffer and have the PCM DMA channel read from this “2-channel mono” buffer, unless there is some way to configure the ASRC and PCM DMA channels such that I can get a consistent L or R output channel in BufferOut.

Assuming that I do need to manually create the “2-channel mono” buffer, I am not sure where that should take place. I don’t see how the ASRC out DMA channel and the PCM DMA channel are synchronized. It seems like DSP0_IRQHandler might be a likely candidate for getting this done, but again I don’t quite see how the buffering and timing is working.

Any help here would be greatly appreciated. Thanks!

You may be best off creating two circular DMA buffers. One could be rather small and would be fed via the ASRC output. With a circular buffer you can interrupt the processor when the buffer is half full and when full. When one of those interrupts occurs, copy the half of the buffer just filled to a new larger buffer that feeds the PCM interface performing the mono to stereo copy. When that copy is done for the first time, enable the PCM interface/DMA.

Thanks @jamie.meacham - this is sort of what I was thinking needed to be done, similar to the way the transmit app using PCM input sets and responds to the 2 DMA interrupts (via rx_DMA_ready_PCM() and RX DMA Handler). I guess what had me stuck was that I didn’t understand how the ASRC and Output Driver DMAs were working/synchronizing, but I just realized that since the ASRC and OD are running at exactly the same rates, then the write to and read from DMAs will alway remain at some fixed offset from one another as the data streams in from the decoder; I hadn’t grasped that until just recently, so now it makes sense that those two DMA channels could just be run in circular mode without generating any interrupts and everything will work out.

Regarding your suggestion, my one concern is will the ASRC DMA always overwrite the last sample of the previous outbound buffer? It seems like there is a synchronization boundary between the ASCR output rate and the PCM input clock (which is externally generated and therefore not synchronized with the ASCR). Perhaps that last sample will have been cached in the PCM DMA channel’s h/w and thus the last memory write from the ASCR DMA channel will not overwrite it. Just wondering if might run into an overwrite problem here.

The job of the ASRC is to cross the synchronization boundary between the data arriving from the radio and the data going out the output interface, in this case the PCM bus. The ASCC is used to measure the clock rate difference between these two domains. So when the ASRC is configured to make the necessary adjustment as measured by the ASCC, it’s output will be synchronous with the PCM interface.

Thanks @jamie.meacham for your help. I have the remote mic RX with PCM output working using the extra buffer and the mono to stereo copy in the ASRC DMA interrupt service routine.

1 Like