Skip to main content

RP2040 Software Design

Hardware to Interface

  • TI TAA3040 - 4 channel audio ADC
    • SPI or I2C control interface
    • TDM audio sample output
  • some stereo DAC - probably another TI part with TDM or I2S input
  • USB interface to present device as input and output channels to a host computer
  • some user interface controls
    • knobs
    • buttons
    • a display would be cool

4-Channel ADC samples in via TDM Interface - WIP

First pass of the PIO program was written, intending to test with another pico providing the TDM output signal

  • PIO program to receive samples on serial pin as a slave to the TAA3040 ADC providing bit clock and sync pulse
  • one 32-bit sample will be pushed to the RX_FIFO at a time, one sample from each channel per TDM frame

3 digital pins

ADC control and configuration via SPI or I2C - TODO

There are a lot of features on the TAA3040 that are configurable by software. For a first pass, just set the chip up in a static configuration and let it go. For future improvement, there are a ton of ways it could be set up and integrated with the USB audio specification.

2-Channel stereo output to DAC via I2S or TDM - TODOWIP

This will take samples returned from the USB host and output to the DAC. This could be I2S as that supports 2 channels no problem. Probably a slightly simpler PIO program than TDM. Select between line output and headphone output.

TDM output of 4 channels has been implemented with PIO. This will allow me to test the 4 channel input side of the code. The program should easily adapt to 2 channels.

3 digital pins

DAC control interface via SPI or I2C - TODO

select a chip that's also controlled via SPI or I2C.

USB Audio interface - TODO

transmit 4 channels of samples to the host, and receive 2 channels back from the host. Also handle configuration - there are a ton of things that could be exposed to the USB host as configurable options and it would be cool to support a lot.

Asynchronous interface since the ADC generates its own clock

USB Audio will transmit a packet of samples every 1ms

Moving sample data with DMA

  • samples can move one at a time from ADC PIO RX FIFO to USB transmit buffer
    • seems like the TX buffer can't directly interface with DMA
    • instead handle interrupt from TinyUSB when tx buffer is empty to set up DMA descriptor to transfer from elsewhere in ram to the USB buffer
    • two steps
      • from pio to generic buffer in memory
      • from buffer to TX buffer when data is required
  • samples can move one at a time from USB receive buffer to DAC output PIO TX FIFO
    • may need to do the same thing handling an interrupt when the rx buffer is filled
      • RX buffer to RAM buffer
      • RAM buffer to PIO TX FIFO
  • bypass mode could move samples from primary input channel to output without going through USB
    • a little latency but definitely less than the 2ms at minimum round trip to/from USB host
  • could have some self-contained mixing capability that would go from ADC channels -> pico software -> DAC channels
  • probably don't need to also implement a total analog bypass, but could provide a physical switch