pico-examples icon indicating copy to clipboard operation
pico-examples copied to clipboard

Add example for SPI with DMA (for reading SPI ADC)

Open DatanoiseTV opened this issue 3 years ago • 0 comments

I am the maker of the PicoADK, a RP2040 powered Audio DSP Board which has a 32-bit Audio DAC and a 8 channel 12-bit SPI ADC with 1 Megasample.

I am trying to get DMA working and to read the 8 channels continuosly (either free-running or at a fixed sample rate), but with no lack so far.

The code to read a single ADC channel without DMA (ADC128S102 IC) looks as following:

uint16_t adc128_read(uint8_t chan)
{
        if (chan > 7)
                return 0;
        gpio_put(13, 0);
        uint8_t data[2] = {(chan << 3), 0};
        uint8_t rxData[2];
        spi_write_read_blocking(spi1, data, rxData, 2);
        gpio_put(13, 1);
        uint16_t result = (rxData[0] << 8) | rxData[1];

        return result;
}

Hardware Reference: https://github.com/DatanoiseTV/PicoADK-Hardware

Any help would be very appreciated.

DatanoiseTV avatar Feb 13 '23 01:02 DatanoiseTV