Abadi alali
Active member
Hello,
I am using teensy 3.6 to interface with the LTC2315-12 ADC demo board. The ADC can reach 5 MSPS if the clock (SCK) is 87.7 MHz.
I was able to make the ADC work but for a maximum of 500 kSPS with SCK = 16 MHz, the problem I am facing that the transaction (from SPI.beginTransaction to endTransaction) is taking around 2 microseconds which is too much for my application. as you can see from my attached code (the part that has the SPI reading only)
this code works for any any t>=2 (which gives me a perfect readings with sampling rate of 1/t but when I try t=1 the code doesn't return done and it hangs after inspecting it I saw that the ADCRead function takes 2 microseconds or more to get a single read and when I try t=1 the interrupt is trigerring in the middle of an SPI read. So is this a limitation of the teensy 3.6 and this is the fastest transaction it can make or is there soemthign wrong I am doing also what are the other ways of doing this other than the interval timer?
Thanks a lot in advance
I am using teensy 3.6 to interface with the LTC2315-12 ADC demo board. The ADC can reach 5 MSPS if the clock (SCK) is 87.7 MHz.
I was able to make the ADC work but for a maximum of 500 kSPS with SCK = 16 MHz, the problem I am facing that the transaction (from SPI.beginTransaction to endTransaction) is taking around 2 microseconds which is too much for my application. as you can see from my attached code (the part that has the SPI reading only)
this code works for any any t>=2 (which gives me a perfect readings with sampling rate of 1/t but when I try t=1 the code doesn't return done and it hangs after inspecting it I saw that the ADCRead function takes 2 microseconds or more to get a single read and when I try t=1 the interrupt is trigerring in the middle of an SPI read. So is this a limitation of the teensy 3.6 and this is the fastest transaction it can make or is there soemthign wrong I am doing also what are the other ways of doing this other than the interval timer?
Thanks a lot in advance
Code:
#include <SPI.h>
IntervalTimer myTimer;
const int slaveAPin = 20;
SPISettings settingsA(8000000, MSBFIRST, SPI_MODE0);
SPISettings settingsB(16000000, MSBFIRST, SPI_MODE0);
volatile unsigned long Count = 0;
void ADCRead(void) {
if (t>3)
SPI.beginTransaction(settingsA);
if (t<= 3){
SPI.beginTransaction(settingsB);
}
digitalWriteFast (slaveAPin, LOW);
SPI0_SR = SPI_SR_TCF;
SPI0_PUSHR = 0 | SPI_PUSHR_CTAS(1);
while (!(SPI0_SR & SPI_SR_TCF)) ; // wait
values[blinkCount]=SPI0_POPR;
digitalWriteFast (slaveAPin, HIGH);
SPI.endTransaction();
Count = Count + 1; // increase when LED ture
}
void main ()
{
if (Serial.available()) {
int c = Serial.read();
if (c =='S'){
t = Serial.parseInt();
Count=0; interrupts(); myTimer.begin(ADCRead, t);
while(blinkCount <=1024);
if (Count >= 1024)
{
noInterrupts();
myTimer.end();
}
else
{
interrupts();
}
Serial.print("done");
}
if (c == 'Q')
{
for(int i=1;i<=1024;i++)
{
Serial.print(i);
Serial.print(" , ");
Serial.println(values[i]);
}
}
}
}