SPI transaction interval
Posted: Sat Jan 05, 2019 6:51 pm
Hi,
I'm making POV display with APA102C leds and ESP32. I have a problem with long interval between next transactions. Even with high clock rate intervals between transactions kills the projet. My configuration of spi interface:
And sender function
Am I doing something wrong or it must take so much time between next transactions?
I'm making POV display with APA102C leds and ESP32. I have a problem with long interval between next transactions. Even with high clock rate intervals between transactions kills the projet. My configuration of spi interface:
Code: Select all
// Configuration for the SPI bus
spi_bus_config_t buscfg = {
.mosi_io_num = DATA_PIN,
.miso_io_num = 5,
.sclk_io_num = CLK_PIN,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = SPI_MAX_DMA_LEN,
};
// Configuration for the SPI master interface
spi_device_interface_config_t devcfg = {
.command_bits = 0,
.address_bits = 0,
.dummy_bits = 0,
.duty_cycle_pos = 128,
.cs_ena_pretrans = 0,
.cs_ena_posttrans = 0,
.clock_speed_hz = 26*1000*1000,
.mode = 0,
.spics_io_num = 17,
.queue_size = 1,
.flags = 0,
.pre_cb = NULL,
.post_cb = NULL,
};
// Initialize and enable SPI
spi_bus_initialize(VSPI_HOST, &buscfg, 1);
spi_bus_add_device(VSPI_HOST, &devcfg, &spi_handle);
Code: Select all
// Full buffer DMA transfer
int32_t spi_dma_transfer_bytes(uint8_t *data, uint16_t size) {
esp_err_t trans_result = ESP_OK;
spi_transaction_t trans_t;
// Prepare transaction parameters
trans_t.rx_buffer = NULL;
trans_t.tx_buffer = data;
trans_t.rxlength = 0;
trans_t.length = 8 * size;
trans_t.flags = 0;
trans_t.cmd = 0;
trans_t.addr = 0;
trans_t.user = NULL;
// Perform transaction
trans_result = spi_device_transmit(spi_handle, &trans_t);
if (ESP_OK != trans_result) {
return -1;
}
return size;
}