Apologies if this has been asked before, but I can't find a similar question after a search...
I'm using an external 5MS/s ADC; www.linear.com/LTC2315-12.
Using SPI.transfer16 on a Teensy 4.1 appears to insert a delay in the order of 120ns between CS going low and the start of the CLK pulses, and another similar delay after the end of the CLK pulses and the CS going high...
This is the same on SPI and SPI1. Using a fast CLK (nearly 80MHz) achieves good results, but with the time overhead of the pre and post CLK delays only about 2MS/s can be achieved.
Best regards,
Chris.
I'm using an external 5MS/s ADC; www.linear.com/LTC2315-12.
Using SPI.transfer16 on a Teensy 4.1 appears to insert a delay in the order of 120ns between CS going low and the start of the CLK pulses, and another similar delay after the end of the CLK pulses and the CS going high...
This is the same on SPI and SPI1. Using a fast CLK (nearly 80MHz) achieves good results, but with the time overhead of the pre and post CLK delays only about 2MS/s can be achieved.
Code:
#include <SPI.h>
SPISettings spiSettings(79000000, MSBFIRST, SPI_MODE0);
const uint8_t CS = 0;
const float resSPI = 4.096 / 4096; //12 bit
void setup() {
// put your setup code here, to run once:
pinMode(CS, OUTPUT);
digitalWriteFast(CS, HIGH);
Serial.begin(115200);
delay(5000);
SPI1.begin();
SPI1.beginTransaction(spiSettings); //Only need to call begin/end transaction once as there is nothing else on SPI1
SPI1.endTransaction();
}
void loop() {
// put your main code here, to run repeatedly:
digitalWriteFast(CS, LOW);
uint16_t vSPI = SPI1.transfer16(0);
digitalWriteFast(CS, HIGH);
vSPI = vSPI >> 3;
Serial.print(vSPI, BIN); Serial.print("\t"); Serial.print(vSPI * resSPI, 5); Serial.println("v");
delay(1000);
}
Best regards,
Chris.