I'm trying to control a dual DAC converter using SPI - the MCP4822 (https://ww1.microchip.com/downloads/en/ ... 02249B.pdf)
I was hoping to be able to send out 2 samples at around 20KHz but seems to be only able to get about half that rate. I thnk each sample needs to be sent as a separate transaction. Is there any way to do this faster?
Thanks
Chris
Code: Select all
// channel A
spi_transaction_t t1;
memset(&t1, 0, sizeof(t1)); //Zero out the transaction
t1.length = 16;
t1.flags = SPI_TRANS_USE_TXDATA;
t1.tx_data[0] = 0b0010000 || ((instruction.x >> 4) & 15);
t1.tx_data[1] = instruction.x;
spi_device_transmit(spi, &t1);
// channel B
spi_transaction_t t2;
memset(&t2, 0, sizeof(t2)); //Zero out the transaction
t2.length = 16;
t2.flags = SPI_TRANS_USE_TXDATA;
t2.tx_data[0] = 0b1010000 || ((instruction.y >> 4) & 15);
t2.tx_data[1] = instruction.y;
spi_device_transmit(spi, &t2);