SPI delay time between transactions.
Posted: Tue Feb 09, 2021 10:16 pm
Hello there,
I'm using SPI communication to interface with an external ADC. I need to send first 1 byte, wait at leas 8us, and then send 3 bytes. I implemented this in 2 different spi_device_transmit (because I need to wait 8us between them).
After seeing the performance of this code through a logic analyzer, I noticed that there is a huge waste of time between this 2 transactions, almost 60us, even though this instructions (spi_device_transmit) are executed one after the other. Image attached.
There's no other tasks running concurrently.
Is there a way to reduce this time between transactions?
In this case, SPI is configured to run at 2MHz (maximum speed to interface with my ADC).
I'm using SPI communication to interface with an external ADC. I need to send first 1 byte, wait at leas 8us, and then send 3 bytes. I implemented this in 2 different spi_device_transmit (because I need to wait 8us between them).
Code: Select all
spi_transaction_t t;
t.flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA;
t.length = 8*1;
t.rxlength = 8*1;
t.tx_data[0] = 0xFF;
t.tx_data[1] = 0xFF;
t.tx_data[2] = 0xFF;
t.rx_buffer = NULL;
spi_transaction_t r;
r.flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA;
r.length = 8*3;
r.rxlength = 8*3;
r.tx_data[0] = 0xFF;
r.tx_data[1] = 0xFF;
r.tx_data[2] = 0xFF;
r.rx_buffer = NULL;
spi_device_transmit(spiHandler, &t);
spi_device_transmit(spiHandler, &r);
There's no other tasks running concurrently.
Is there a way to reduce this time between transactions?
In this case, SPI is configured to run at 2MHz (maximum speed to interface with my ADC).