Teensy 3.5 (maybe 3.1) CPU, BUS and SPI speed experiments

Status
Not open for further replies.

alex-arc

Active member
I am starting this thread so someone can yell at me if i do something stupid :eek: and share the results of my experiments, or should this be on the Beta Test thread?

I started looking at the SPI library and add comments from the data sheet https://github.com/alex-Arc/SPI/blob/doc/SPI.cpp
on line 166 and 167 CTAR0 and CTAR1 is defined but with frame size 7 and 15 respectively, anyone know why?

is there a good way to measure the speed of the teensy? i tried this:
Code:
unsigned long mics = 0;
unsigned long micsDiff = 0;

void setup() {
  Serial.begin(9600);
  delay(1000);
  Serial.printf("F_CPU %u   F_BUS %u \n", F_CPU, F_BUS);

  mics = micros();
  //delayMicroseconds(1);
  micsDiff  = micros();
  micsDiff -= mics;
  unsigned int measureTime = micsDiff;
  Serial.printf("measured time: %u \n", micsDiff);

  mics = micros();
  __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); __asm__("nop\n\t"); 
  micsDiff = micros();
  micsDiff -= mics;

  Serial.printf("measured time: %u without measuretime: %u singel cycle: %f*\n", micsDiff, micsDiff-measureTime, (micsDiff-measureTime)/40);
  
  
}

void loop() {
  
}
on at teensy 3.5 at 24 MHz and got:

F_CPU 24000000 F_BUS 24000000
measured time: 1
measured time: 3 without measuretime: 2 singel cycle: 2.484428

that seems quite a bit of, do
Code:
__asm__("nop\n\t");
not represent one cycle?
 
Last edited:
Status
Not open for further replies.
Back
Top