Page 1 of 1

High-speed SPI communication

Posted: Thu Nov 09, 2023 12:43 pm
by akk8222
Hi there,
I want to send a large number of 16-bit format signals (about 2^13 patterns) and at high speed via SPI communication using an ESP32.
I created a program to send two formats and checked the protocol. Then, there is an issue that after ssPin(Select) goes low, sckPin(Clock) starts outputting too late to send. Is there any way to reduce this time?

Code: Select all

#include <SPI.h>
const int ssPin = 5;    
const int sckPin = 18;  
const int mosiPin = 23; 
const int misoPin = 19; 

uint16_t dataWRITE[2] = {0x1234, 0xABCD}; 

void setup() {
  // put your setup code here, to run once:
  SPI.begin();
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
  pinMode(ssPin, OUTPUT);
  digitalWrite(ssPin, HIGH); 
}

void loop() {
  // put your main code here, to run repeatedly:
  for (int i = 0; i < 2; i++){
    digitalWrite(ssPin, LOW); 
    SPI.transfer16(dataWRITE[i]);
    digitalWrite(ssPin, HIGH); 
  }
    delay(1000);
  
}
protocol.JPG
protocol image.
protocol.JPG (61.09 KiB) Viewed 524 times