K66 Beta Test

Status
Not open for further replies.
For you old-timers who remember the mainframe "Whetstone" (floating point) and "Dhrystone" (integer) benchmark programs, I ran a version of them on the Teensy 3.6. The results are:
19 MOPS 64-bit floating point
28 MOPS 32-bit floating point
223 MOPS 32-bit integer
For a $30 computer, that's about $0.13 per integer MIPS, which is about three million times cheaper than computers in 1980!
 
For you old-timers who remember the mainframe "Whetstone" (floating point) and "Dhrystone" (integer) benchmark programs, I ran a version of them on the Teensy 3.6. The results are:
19 MOPS 64-bit floating point
28 MOPS 32-bit floating point
223 MOPS 32-bit integer
For a $30 computer, that's about $0.13 per integer MIPS, which is about three million times cheaper than computers in 1980!

FWIW, dhrystone is dominated by a call to strcmp with the second argument being a 31 byte character literal (line 1053 in my copy of the benchmark). Around 30 years ago, for the Motorola 88000 GCC port, I was able double the performance of GCC on this silly benchmark by converting strcmp of character literals to memcmp, and then open coding memcmp's of fixed lengths that were small enough.

For whetstone, for module 7 (trig functions), you might get a speed boost for 32-bit floating point if you use the version that is targeted towards single precision (i.e. sinf, cosf, and atan).
 
PORTB |= (1 << 5); // turn led on (pin 13 high)

This works for turning the teensy 3.6 onboard LED on:
DDRB |= (1 << 5);
PORTB |= (1 << 5);

Initially, I was setting C5 high because all the maps here indicate that teensy 3.6 pin 13(LED) maps out to native C5. But my code works when I set B5 high. Why is there an apparent inconsistency or am I being naive here?

Not as pretty as the card, but with a bit more information (I2S, Ethernet, Native Port)

View attachment 8085

It's a LibreOffice Calc file (*.ods) which you can download here:
https://www.dropbox.com/s/23yl6hxqmp0h2u9/T3.6pinoutDiagram.ods?dl=0

So far I compiled the info from Pauls official card and what can be found in this picture in Post #8:
View attachment 7888


Ben
 
This works for turning the teensy 3.6 onboard LED on:
DDRB |= (1 << 5);
PORTB |= (1 << 5);
That's the AVR port emulation (a C++ class that pretends to be a port register).

Initially, I was setting C5 high because all the maps here indicate that teensy 3.6 pin 13(LED) maps out to native C5. But my code works when I set B5 high. Why is there an apparent inconsistency or am I being naive here?
The native port registers are GPIOC_Pxxx with versions for setting / clearing / toggling pins.
 
That's the AVR port emulation (a C++ class that pretends to be a port register).


The native port registers are GPIOC_Pxxx with versions for setting / clearing / toggling pins.

Thank you for the clear and concise answer. It gave me the right keyword for searching online: "AVR port emulation". I learnt that "digitalWriteFast(pin, value)" is the same as "PORT |= (1<<pin)". :)
 
But be aware that the math functions are for double which on the most arduino-boards is equal to float :mad:
So, better use their float-versions
 
Last edited:
But be aware that the math functions are for double which on the most arduino-boards is equal to float :mad:
So, better use their float-versions

Frank - I assume this note was in reference to the wiki post? I just put this::
Arduino Reference :: Primary Arduino as well as Standard C reference info - be alert for better 32 bit ARM Teensy math or other::
https://www.arduino.cc/en/Reference/HomePage

Arduino Libraries Summary - some may have ported or improved Teensy code::
Reference/Libraries
 
Hello,i want to use the spi1 in teensy 3.6.
According to this photo

https://forum.pjrc.com/attachment.php?attachmentid=8067&d=1473211335

must use digital pin 0,1,32 and 31 which correspond to the ports B10, B11, B16 and B17.

I wrote(red color)to set spi1 but do not read the sensor.

Code:
#include <SPI.h>

#define CS1 31

double gyro_pitch, gyro_roll, gyro_yaw;
byte highByte, lowByte;

void setup() {

 [COLOR="#FF0000"] SIM_SCGC6 |= SIM_SCGC6_SPI1;
  PORTB_PCR10 = PORT_PCR_MUX(2);
  PORTB_PCR11 = PORT_PCR_MUX(2);
  PORTB_PCR16 = PORT_PCR_MUX(2);
  PORTB_PCR17 = PORT_PCR_MUX(2);
[/COLOR]
  Serial.begin(9600);

  SPI.begin();
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
 .
 .
 .
 }

 void loop() {
 .
 .
 .
 }

Can help?
 
Hello,i want to use the spi1 in teensy 3.6.
According to this photo

https://forum.pjrc.com/attachment.php?attachmentid=8067&d=1473211335

must use digital pin 0,1,32 and 31 which correspond to the ports B10, B11, B16 and B17.

I wrote(red color)to set spi1 but do not read the sensor.

Code:
#include <SPI.h>

#define CS1 31

double gyro_pitch, gyro_roll, gyro_yaw;
byte highByte, lowByte;

void setup() {

 [COLOR="#FF0000"] SIM_SCGC6 |= SIM_SCGC6_SPI1;
  PORTB_PCR10 = PORT_PCR_MUX(2);
  PORTB_PCR11 = PORT_PCR_MUX(2);
  PORTB_PCR16 = PORT_PCR_MUX(2);
  PORTB_PCR17 = PORT_PCR_MUX(2);
[/COLOR]
  Serial.begin(9600);

  SPI.begin();
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
 .
 .
 .
 }

 void loop() {
 .
 .
 .
 }

Can help?

assuming your spi1 pin selection, use this for setting the spi1 ports on teensy

Code:
		CORE32_PIN_CONFIG  = PORT_PCR_MUX(2) | PORT_PCR_SRE | PORT_PCR_DSE ; // CLK SRE slew rate enable, DSE drive strength enable 
		CORE_PIN0_CONFIG   = PORT_PCR_MUX(2) | PORT_PCR_SRE | PORT_PCR_DSE ; // MOSI
		CORE_PIN1_CONFIG  = PORT_PCR_MUX(2) | PORT_PCR_SRE | PORT_PCR_DSE;	 // MISO

I guess you wanted to use dig pin 31 for CS then use
Code:
pinMode(31,OUTPUT);
 
wmxz not working.

if you use SPI.begin after the port changes than SPI will use default values.
You should use spi1 setCLK(pin), setMOSI(pin), setMISO(pin) functions after call SPI.begin

I also assume it should be SPI1.begin etc.

Edit: see KurtE on where to set clk (i.e. before begin not after I assumed)
 
Last edited:
I have connected a gyroscope sensor with SPI1.

I cannot see how you set up the Serial (which is USB-serial). maybe you have a fault before terminal is up.
try r use
Code:
 while(!Serial); 
Serial.println("Gyro test");
before doing anything else in setup
 
Yes now works, why has this problem?

A part of the code is

Code:
#include <SPI.h>

#define CS1 31

unsigned long a;
double gyro_pitch, gyro_roll, gyro_yaw;
byte highByte, lowByte;

void setup() {

  while(!Serial); 
  Serial.println("Gyro test");

[COLOR="#FF0000"]  SIM_SCGC6 |= SIM_SCGC6_SPI1;
  PORTB_PCR10 = PORT_PCR_MUX(2);
  PORTB_PCR11 = PORT_PCR_MUX(2);
  PORTB_PCR16 = PORT_PCR_MUX(2);
  PORTB_PCR17 = PORT_PCR_MUX(2);[/COLOR]

  Serial.begin(9600);

  SPI1.begin();
  SPI1.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));

  pinMode(CS1, OUTPUT);
  .
  .
  .
}

Αs it said now works correctly,these i have written in red is right for active spi1?

Thanks for the help.:)
 
Those lines in red should not be necessary. SPI1.begin() does that for you.

I think I know what the problem was. When I implemented SPI1, I was not sure which were the default pins for some of the signals.
So I believe the code is currently setup for SCK1 on pin 20 not 32.

My guess is that the following should work for you:
Code:
  SPI1.setSCK(32);
  SPI1.begin();
  SPI1.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
Paul if you want, I could issue a Pull request to change the default to 32 to match the card.

Kurt

Update: I added this change to core pull request #173, which added more Miso/Mosi/SCK pin for SPI0...
 
Last edited:
I think I know what the problem was. When I implemented SPI1, I was not sure which were the default pins for some of the signals.
So I believe the code is currently setup for SCK1 on pin 20 not 32.

My guess is that the following should work for you:
Code:
  SPI1.setSCK(32);
  SPI1.begin();
  SPI1.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));


KurtE yes it work, thank you.:)
 
According to the datasheet to set a port into input should

"PDD-Port Data Direction

Configures individual port pins for input or output.

0 Pin is configured as general-purpose input, for the GPIO function.
1 Pin is configured as general-purpose output, for the GPIO function.
"

To set the port B18 as output should write

GPIOB_PDDR = (1 << 18);

in order to set as input what you should write?
 
Status
Not open for further replies.
Back
Top