SPI transaction sending speed

iamflimflam1
Posts: 12
Joined: Fri May 22, 2020 7:58 am

SPI transaction sending speed

Postby iamflimflam1 » Mon Jan 11, 2021 10:01 pm

Hi All,

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);

iamflimflam1
Posts: 12
Joined: Fri May 22, 2020 7:58 am

Re: SPI transaction sending speed

Postby iamflimflam1 » Tue Jan 12, 2021 5:14 am

Looks like I should be using `spi_device_polling_transmit`

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 99 guests