Teensy 3.1 overclock to 168MHz

yes to both and it's further reduced because @ 2 MHz it goes into Very Low Power Run (VLPR) mode. These chips have awesome low power options.
 
At 2 MHz, a special VLPR (very low power run) mode is used.

Freescale doesn't document exactly how VLPR mode implemented in the silicon, but my best guess is they have an internal voltage regulator that's reducing the VCC voltage inside the chip to a very low level. It makes quite a dramatic difference.

Today we're seeing about 2.3 mA while running at 2 MHz. In theory, about 1 mA should be possible. My hope is we'll eventually figure out a better way to initialize the chip in mk20dx128.c that gets to only 1 mA, but I didn't want to hold up the 1.19 release for this. 1.19 has a number of bug fixes that really make Teensy as much more solid platform.
 
Bit 31 in Register SOPT1 defaults to 1, the other Bits are interesting too. You can switch of the "USB Voltage Regulator" with this. Maybe this save some 1/10 of mA
 
Yes, disabling USB will reduce power, thats what I do in my low power library when using reduced speed or in sleep modes. I have routine to put the teensy in VLPW and with out disabling USB it will sleep at ~900 uA and ~500 uA with USB disabled.
 
Hiya, Im desperate to try getting 144Mhz working, I'm running dual oled screens (SPI) and all sorts so really need the extra speed... However... no Joy..

I've downloaded the latest v1.19 teensyduino, I've replaced the core files for the Teensy install, and that lets me upload fine and everything runs as normal (96Mhz)..

The minute I replace the boards.txt file with the one from gitHub (https://raw.githubusercontent.com/FrankBoesing/Teensy-Core-168MHz-Overclock/master/boards.txt) My teensy program crashes a few seconds into the program (before getting out of setup() part of the sketch)..

It doesnt seem to matter what speed I try, same result.. as soon as I go back to the original boards.txt, it works just fine.. Any Ideas?

Im running MP3 system via Serial1, SD Data Logger via Serial3, 2 X SPI Adafruit Oleds, rotary encoder, INA219 current sensor via i2C, USBHostBoard (PS3 Controller), RTC mod, and a couple of NEOPixels.. I think that's the main stuff..

The crash happens essentially at the point where the OpenLog SD logger starts up.. but doesnt seem to be the prob, since when I comment out the SDLogger same thing.

Am i Missing something?

Thanks for any help you can offer guys

Cheers

Andy
 
With a fresh 1.19 install, all you should need to do is edit boards.txt and uncomment the lines to enable higher speeds.

Your boards.txt appears to have several other modifications. I'd suggest just trying 1.19's boards.txt, with the only change to uncomment the higher speed lines.

Of course, there's no guarantee 144 MHz will really work. That is double the chip's rated speed! ;)
 
Last edited:
Probably won't mater, but what I have done, is to install 1.19 and when I was looking at it's new boards.txt, I noticed that it had the other CPU speeds in it, but commented out, so I uncommented them and then they show up, Currently doing most of my playing at 144...

Kurt
 
Also, with overclocking, consider that 144 and 168 MHz modes overclock the flash memory. 144 MHz mode overclocks the flash by 20% and 168 MHz overclocks it by 40%.

168 MHz mode also overclocks the peripherals by 17%.

120 MHz mode runs the flash memory within spec, but overclocks peripherals by 25%.

96 MHz mode runs the flash and peripherals within spec, and it's only a modest overclock of the CPU. I personally test nearly all code at 96 MHz and everything has worked very well at this speed.

But technically, anything over 72 MHz on Teensy 3.1 and anything over 48 MHz on Teensy 3.0 is overclocking.
 
Ahh man, that was easy ;)

Sorry, i'd completely misunderstood another post, I thought I had to use the boards.txt file from FrankBoesing to open up the options (Doh, just comment them out..). Good stuff, so all good on the 120 & 144 but totally not a happy chappy on the grand 168 scheme of things.. Not actually sure the oled animations are any quicker, despite the difference between 48Mhz & 96Mhz being pretty obvious in terms of animation rendering on the Oleds..

I've been a PC overclocker for at least 20 years, my current system is custom watercooled system, which reminds me (on the overclock H²o front), came accross something a while back that i'm gagging to find an excuse to use for overclocking something small like a teensy:

http://www.hobbyking.co.uk/hobbykin..._with_Self_Circulating_Pump_And_Radiator.html

that would rock ;) (just for show obviously)

Thanks for your help, it was very obvious in the end, just didnt see anything anywhere on the main website regarding uncommenting the boards.txt.. off to soak test... :)

You bloody rock Paul, I think i'll put my 3 X Arduino Mega 2 X uno's and 4+Nano's on ebay.. since you've happily made them obsolete ..
 
On those OLED displays, SPI performance is probably limiting the speed. Running the CPU faster will just spend more cycles waiting on the SPI bus, which runs at the same speed regardless of what you do for the CPU (unless the CPU runs very slow).

Adafruit's libraries are designed for portability and code reuse, often at the expense of performance. Most of their libs that use SPI also can do bit-bashing to emulate SPI in software. That lets you use any set of pins, but it also tends to be slow. First, make sure you're using hardware SPI and not the software emulated SPI.

For really fast speed, you'll need to edit the library or switch to a higher performance library (if any exist for that OLED).
 
Thanks for your response,
yeah, i'd looked into the whole SPI hardware business and (I think) it's running in hardware mode, heres the pins i'm using (OLEDs = 2 X 1.3" Adafruit 128x64 SSD1306)
Code:
// NEW FOR FAST HARDWARE SPI PERFORMANCE!
#define OLED_DC 5     
#define OLED_CS 28    // DUMMY SO I CAN CONTROL MANUALLY FOR DUAL OLEDS
#define OLED_CLK 13   
#define OLED_MOSI 11  
#define OLED_RESET 6

i've followed the post here which speeds up the Adafruit_SSD1306 library up too. Not sure what else I can do as i don't understand bit bashing with enough confidence to start playing; but I do find myself being restricted somewhat by the max speed i'm getting. If I could squeeze a bit more speed out of the teensy / SPI / Library etc then it would allow me to run 3 screens simultaneously rather than 2. I have some highly complex graphics / fast moving graphs and high speed animations all going at once on 2 separate screens plus running speech synthesis, plus logging 8 sensors each at 8ms interval, plus tracking all buttons and controls on a PS3 controller, plus SD data logging every 500ms, and 3 other I2C modules all at once.. I think you get the picture lol.. it's intense, but absolutely shows what the teensy is capable of! (running out of RAM, running out of Pins, but certainly not running out of enthusiasm for this little beast!

Anyway, babbling now.. but yeah, essentially, any little tricks anyone may have to squeeze more out of those screens or SPI hacks etc im listening, I'd be interested to get this thing stable at 168Mhz but from what you're saying Paul, everything beyond 144 is gonna be more down to other bits to polish up to get the extra speed... oohh, the thought of 3 OLEDS, yummy (I animate content going across the 2 screens like multiplex stylee so a third would be great!) :)

Cheers peeps

Andy
 
For what it is worth, I hacked up the driver for the Adafruit 2.8" tft display(ILI9341) with touch, for high speed using the tricks that Paul did earlier for some other displays and sped it up a lot. One issue you run into is you want the hardware SPI to control the chip select as well as the Data/Control pin. I believe that you only have that option with IO pins: 2, 6, 9, 10, 15, 20-23
Note: Some of these IO pins are duplicates (as per SPI), which you can control up to 6 pins as part of the SPIx_PUSHR register.

If you can not use these IO pins, but still using the standard SPI pins for CLK and MOSI (and if needed MISO) then you can still use the SPI library code. My version falls back to this if needed.

More details of what I did in the thread: http://forum.pjrc.com/threads/25718-Adafruit-2-8-quot-TFT-Touch-Shield-for-Arduino-for-Teensy-3-1
 
Hey KurtE, I'll take a look, thanks,

Problem I've got with the CS is that I have to take over control of that manually since I have 2 x CS; one for each screen, essentially I draw each screen alternately, approx 100fps each screen every loop every screen, hence I can't have a single delay / while loop etc etc anywhere in the code. It's been healthy for me though as it's forced me to rethink the way I build 100kb+ sketches using no delays, and no interrupts even.

Just to complicate things further, I've got several i2c devices plus 3 sets of serial comms used up so my options for pins are becoming limited, the TX2 pin (CS) is taken but anyway, what would I do with the other CS pin? At the moment they're on 22 & 23.

I'm pretty new to oleds so although I feel I'm learning quickly, I'm not overly confident with writing custom libraries etc but I'll take a look at your link.

Let me know if I'm missing something obvious, just got that niggling feeling.

Cheers
 
I am not an expert on this by any measure, but the datasheet http://www.pjrc.com/teensy/K20P64M72SF1RM.pdf helps...

As for manually controlling the CS pins, I am not sure you need to do this manually, I only have one of this shield, plus one of the 1.8" tft shields. With the fast hardware setup, your request to output data to the screen is done through a FIFO queue with 4 entries, each entry is 32bits long, with the lower word with the byte or word of data to shift out and the upper word contains control info. Part of this control info tells the 6 chip select pins what to do. Assuming that you can get all of their CS pins into the pins associated with the 6 CS pins of the SPIx_PUSHR, you can then interleave requests for the multiple devices and the system will automatically update the CS and the DC pins at the appropriate time.

There are still areas of these SPI registers I am still fumbling with. For example knowing when my set of TX's are completely done, as I wish to then do something. Or the best way to empty the read queue... But I am learning.

Wonder if this should continue on different thread?
 
I ran the speed test to compare Teensy 3.0 v.s. Teensy 3.1 v.s. my own board, which is using an MK22 chip. The results are pretty interesting.



Teensy 3.0
Speed test
----------
F_CPU = 120000000 Hz
1/F_CPU = 0.0083 us
The next tests are runtime compensated for overhead
nop : 0.008 us
avr gcc I/O : 0.146 us
Arduino digitalRead : 0.338 us
Arduino digitalWrite : 0.866 us
pinMode : 0.741 us
multiply volatile byte : 0.073 us
divide volatile byte : 0.153 us
multiply volatile integer : 0.071 us
divide volatile integer : 0.093 us
multiply volatile long : 0.073 us
multiply single float : 1.368 us
multiply double float : 1.623 us
divide double float : 24.633 us
itoa() : 0.948 us
ltoa() : 2.383 us
dtostrf() : 128.083 us
random() : 0.858 us
y |= (1<<x) with volatile : 0.071 us
bitSet() with volatile : 0.073 us
analogReference() : 2.243 us
analogRead() : 7.733 us
analogWrite() PWM : 2.518 us
delay(1) : 1001.483 us
delay(100) : 99999.983 us
delayMicroseconds(1) : 1.032 us
delayMicroseconds(5) : 5.041 us
delayMicroseconds(100) : 100.283 us
-----------

Teensy 3.1
Speed test
----------
F_CPU = 120000000 Hz
1/F_CPU = 0.0083 us
The next tests are runtime compensated for overhead
nop : 0.008 us
avr gcc I/O : 0.086 us
Arduino digitalRead : 0.116 us
Arduino digitalWrite : 0.379 us
pinMode : 0.196 us
multiply volatile byte : 0.050 us
divide volatile byte : 0.089 us
multiply volatile integer : 0.050 us
divide volatile integer : 0.059 us
multiply volatile long : 0.049 us
multiply single float : 0.381 us
multiply double float : 0.551 us
divide double float : 10.174 us
itoa() : 0.424 us
ltoa() : 1.499 us
dtostrf() : 80.124 us
random() : 0.274 us
y |= (1<<x) with volatile : 0.041 us
bitSet() with volatile : 0.041 us
analogReference() : 1.315 us
analogRead() : 6.849 us
analogWrite() PWM : 1.679 us
delay(1) : 999.999 us
delay(100) : 99999.999 us
delayMicroseconds(1) : 1.002 us
delayMicroseconds(5) : 5.010 us
delayMicroseconds(100) : 100.149 us
-----------

My board
Speed test
----------
F_CPU = 120000000 Hz
1/F_CPU = 0.0083 us
The next tests are runtime compensated for overhead
nop : 0.008 us
avr gcc I/O : 0.086 us
Arduino digitalRead : 0.119 us
Arduino digitalWrite : 0.374 us
pinMode : 0.189 us
multiply volatile byte : 0.050 us
divide volatile byte : 0.074 us
multiply volatile integer : 0.049 us
divide volatile integer : 0.059 us
multiply volatile long : 0.051 us
multiply single float : 0.369 us
multiply double float : 0.601 us
divide double float : 9.149 us
itoa() : 0.424 us
ltoa() : 1.599 us
dtostrf() : 64.899 us
random() : 0.274 us
y |= (1<<x) with volatile : 0.041 us
bitSet() with volatile : 0.041 us
analogReference() : 0.879 us
analogRead() : 6.749 us
analogWrite() PWM : 1.504 us
delay(1) : 999.999 us
delay(100) : 99999.999 us
delayMicroseconds(1) : 1.002 us
delayMicroseconds(5) : 5.008 us
delayMicroseconds(100) : 100.149 us
-----------



Hope you find the results interesting.
Using just a counting loop and checking how many iterations in one second as referenced from an accurate clock source (RTC) shows the teensy 3.0 is actually the fastest.
This makes me wonder about the assumptions one can make from these results, and the differences within the die for the CPU core.
 
iam a not a programmer,
what means this?

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 + Td: 1.20 (Windows 7), Board: "Teensy 3.1"
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp: In function 'void yield()':
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:43:38: error: 'serialEvent' was not declared in this scope
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:44:40: error: 'serialEvent1' was not declared in this scope
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:45:40: error: 'serialEvent2' was not declared in this scope
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:46:40: error: 'serialEvent3' was not declared in this scope


the only library i use its #include <SoftwareSerial.h> for sending some numbers to a serial Led display, nothing returns , no another serial or usb input. i will only test overclocking helps make the program faster.

Dirk
 
Last edited:
That seems to have nothng to do with overclocking.
However, why use software serial when Teensy 3.1 has three hardware serial channels in addition to serial over USB?
 
Why indeed use SoftwareSerial.

Actually, I can think of a couple libraries that have hard-coded dependency on SoftwareSerial, and several example sketches that use it only because it's the only option on Arduino Uno.

But why specifically, we can't know, because the complete source code to reproduce the problem wasn't posted.
 
Ok
Your right PaulStoffregen :)
The Code is:
Code:
//Display
#include <SoftwareSerial.h>

// These are the Arduino pins required to create a software seiral
//  instance. We'll actually only use the TX pin.
//SoftwareSerial Serial7Segment(0, 1); //RX pin, TX pin

const int softwareTx = 10;
const int softwareRx = 9;

SoftwareSerial Serial7Segment(softwareRx, softwareTx);

// Send the clear display command (0x76)
//  This will clear the display and reset the cursor
void clearDisplay()
{
  Serial7Segment.write(0x76);  // Clear display command
  //    Serial7Segment.write(0x81); // Send factory reset command
}
//  Set the displays brightness. Should receive byte with the value
//  to set the brightness to
//  dimmest------------->brightest
//     0--------127--------255
void setBrightness(byte value)
{
  Serial7Segment.write(0x7A);  // Set brightness command byte
  Serial7Segment.write(value);  // brightness data byte
}

// variablen and pin declaration
int PotConst2 = A1;
int PotConst1 = A8;
int PotConst1Value;
int PotConst2Value;
float varstar = 465849;  // 467470  // 0.348% error (5min) 465848.846
float varsun = 466161;
float varmoon = 451109;
long previousMillis = 0;
long previousMicros = 0;
const int StarPin = 16;
const int SunPin = 17;
const int MoonPin = 18;
const int ConstPin = 19;
int starstate = 0;
int sunstate = 0;
int moonstate = 0;
int conststate = 0;


// the setup routine 
void setup() 
{                
  pinMode(16, INPUT);
  pinMode(17, INPUT);
  pinMode(18, INPUT);
  pinMode(19, INPUT);
  pinMode(7, OUTPUT);
  digitalWriteFast(7, LOW);
  pinMode(13, OUTPUT);
  digitalWriteFast(13, LOW);
  // initialize serial communication at 9600 bits per second:

  Serial7Segment.begin(9600);

  // setBrightness(0);  // Lowest brightness
  // setBrightness(127);  // Medium brightness
  setBrightness(255);  // High brightness

  clearDisplay();
}
void loop() {
  digitalWriteFast(7, LOW);

  starstate = digitalReadFast(StarPin);
  if (starstate == HIGH) { 
    star();
  }
  else  { 
    moonstate = digitalReadFast(MoonPin);
    if (moonstate == HIGH)     { 
      moon();
    }
    else  { 
      sunstate = digitalReadFast(SunPin);
      if (sunstate == HIGH)     { 
        sun();
      } 

      else  { 
        conststate = digitalReadFast(ConstPin);
        if (conststate == HIGH)   { 
          constant();
        }
      }

    }                     
  }

}                   

void star(){ 
  Serial7Segment.print("STAR"); 
  unsigned long currentMicros = micros();
  if(currentMicros - previousMicros > varstar) 
  {
    previousMicros = currentMicros; 
    digitalWriteFast(7, HIGH);  
   } 
}

void moon(){ 
  Serial7Segment.print("Eoon");  
  unsigned long currentMicros = micros();
  if(currentMicros - previousMicros > varmoon) 
  {
    previousMicros = currentMicros;  
    digitalWriteFast(7, HIGH); 
  } 
}

void sun(){ 
  Serial7Segment.print(" Sun");  
  unsigned long currentMicros = micros();
  if(currentMicros - previousMicros > varsun) 
  {
    previousMicros = currentMicros;  
    digitalWriteFast(7, HIGH); 
  }
}

void constant() {
  PotConst2Value = analogRead(PotConst2);
  PotConst1Value = analogRead(PotConst1);
  int interval1 =map(PotConst1Value, 0, 1023, 0, 9899);
  int interval2 =map(PotConst2Value, 0, 1023, 1, 100);
  displaydigits(interval1 + interval2);
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval1 + interval2) 
  {
    previousMillis = currentMillis;  
    digitalWriteFast(7, HIGH);  
  }
}                    

void displaydigits(int dig)  
{
  Serial7Segment.write("w");  
  Serial7Segment.write(256);   
  if ((dig < 10) && (dig >= 0)){//1
    Serial7Segment.print("XXX");
    Serial7Segment.print(dig);
  }
  if ((dig >= 10) && (dig < 100)){
    Serial7Segment.print("XX");
    Serial7Segment.print(dig); 
  }
  if ((dig >= 100) && (dig < 1000)){
    Serial7Segment.print("X");
    Serial7Segment.print(dig); 
  }  
  if (dig >= 1000){
    Serial7Segment.print(dig); 
  }

  if ((dig < 0) && (dig > -10)){//1
    Serial7Segment.print("XX");
    Serial7Segment.print(dig);
  }

  if ((dig <= -10) && (dig > -100)){
    Serial7Segment.print("X");
    Serial7Segment.print(dig); 
  }
  if (dig < -100){
    Serial7Segment.print("");
    Serial7Segment.print(dig); 
  }
}

nothing complicated, very simple like a non programmer.
i go back to Arduino 1.0.5 and the same . why i think its a problem whit 1.0.6 and uninstall all polulu stuff.
no change.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.5-r2 (Windows 7), Board: "Teensy 3.1"
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp: In function 'void yield()':
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:43:38: error: 'serialEvent' was not declared in this scope
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:44:40: error: 'serialEvent1' was not declared in this scope
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:45:40: error: 'serialEvent2' was not declared in this scope
C:\Program Files (x86)\Arduino\hardware\teensy\cores\teensy3\yield.cpp:46:40: error: 'serialEvent3' was not declared in this scope

one question, i understand this right?
i make this like this description down on the page https://github.com/FrankBoesing/Teensy-Core-168MHz-Overclock and i can override without something typing in my code or i need to type something in the code?
i use this led display https://www.sparkfun.com/products/11441
and this are the schematic
Schaltplan star track device.jpg

Dirk
 
Last edited:
@ Nantonos

your men something like this?

http://forum.pjrc.com/threads/26567-Sparkfun-LCD-module-w-daughter-board?highlight=hardware+serial

PaulStoffregen

Join Date
Nov 2012
Posts
5,179

I looked at this code briefly. It seems ok, except you'll probably want to edit this line:

Code:

//initialize an instance of the SoftwareSerial library
SoftwareSerial serial(2,3);//change these two pin values to whichever pins you wish to use (RX, TX)

To something like this:

Code:

// use a real serial port, instead of SoftwareSerial
#define serial Serial1

Of course, if using Serial1, connect to pins 0 and 1, not pins 2 and 3.


Iam a non Programmer :-( and i try the best learning every time something.. i will take a look to this later,
thanks for this comment and or tip :)

Dirk
 
Back
Top