Short form:
I'm trying to send a packet of three bytes via SPI using spi_m_sync_transfer(). I'm seeing a 100 uSec gap between each byte.
- is this to be expected?
- what should I do to send 3 bytes without a gap?
Details:
Hardware is SAMD11 XPlained Pro board. CPU and SERCOM1 are running off a 48MHz clock (from DFLL48M)
Dev Env is Atmel Microchip Studio v 7.0.2542.
CONF_GCLK_SERCOM1_CORE_FREQUENCY is 48000000 (48MHz) as expected.
CONF_SERCOM_1_SPI_BAUD is 2500000 (2.5Mhz) as expected.
Clock rate for the SPI is 2.5MHz, and measures properly on my 'scope.
Code:
#include "atmel_start.h" #include "atmel_start_pins.h" static uint8_t pixels[] = {0x01, 0xfe, 0x55}; // 3 pixels int main(void) { uint32_t retval; struct spi_xfer xfer = { .rxbuf = NULL, .txbuf = pixels, .size = sizeof(pixels) }; atmel_start_init(); spi_m_sync_enable(&RGB_COM); do { retval = spi_m_sync_transfer(&RGB_COM, &xfer); // write 3 pixels delay_ms(1); } while (retval == sizeof(pixels)); // arrive here if spi_m_sync_transfer() failed while (1) { asm("nop"); } }
What I expect:
I expect to see a burst of three bytes sent back-to-back with a 1 mSec delay between each burst.
What I observe:
I see three bytes sent with a 100 uSec gap between each byte, followed by a 1 mSec delay.