Teensy 4.0 First Beta Test

Status
Not open for further replies.
Thanks to everyone for so much awesome testing in the last several hours!

I've updated msg #6 with a few new issues, and I deleted many that are fixed (and confirmed fixed). Things are moving fast & this thread is growing long. If you find an issue or see something reports that's not yet on msg #6, please add it (if you have "plus" user access to edit messages).

I'm going to take several hours off this evening for New Year's... will be back in the early hours of 2019, to get onto fixing the C++ vtables and constructor stuff and other issues.

Happy New Year to everyone!!
 
Wow - you are doing awesome work and reading and collecting details! I just saw you found my post #117 note - I'll update as it seems to be any time it is over 10 seconds testing iterations.

Have a good night - and a happy New Year.
 
Double and single precision floating point looks good.
Code:
Linpack 100x100 mflops
               double    float
  1170@996mhz  120.3     289     NXP SDK -O3  10/19/21
  T4@600mhz     71.4     166.3   gcc -O3
  M7@600mhz     66.97    125.5   ARM CC -O3        
  T3.6@256mhz    2.85     41.1   Fastest
  T3.6@180mhz    2.13     28.4   Faster
  T3.5@120mhz    0.88     19.2   Faster
  T3.2@120mhz    0.65      1.0   Faster  no FPU
  ESP32@240mhz   2.8      44.5
  adaM4F@120mhz  1.4      20.1   SAMD51 
  STM32L4@80mhz  0.88     15.4   dragonfly -O2
  STM32F405@168  1.8      28.3   -O2 adafruit
  F767ZI@216mhz 24.1      47.5   ARM CC -O3
linpackbar.png

dsp.zip contains files to support M7 DSP (arm_math.h v1.5.1) on Teensy 4. I tested with a DSP benchmark.
Code:
DSP FFT benchmark  1024  radix4 REVERSEBITS 0  (microseconds)
                q15     q31      f32
  T4@600mhz     77.4    147.0     87.0    gcc -O2     arm_math.h v1.5.1
  M7@600mhz     77.4    147.8     88.0    gcc -O3     arm_math.h v1.5.1 SDK
  M7@600mhz     74.5    126.9     95.6    ARM GCC -O3   arm_math.h v1.5.1
1170@996mhz     44.3     90.6     65.2    gcc -O3   v1.6.0 SDK
T3.6@256mhz    291.7    720.4    424.7    Faster    v1.5.3
T3.6@240mhz    311.2    768.8    453.0    Faster    v1.5.3
T3.6@180mhz    463.1   1215.2    703.7    Faster    v1.1.0
T3.6@180mhz    414.7   1010.7    598.2    Faster    v1.5.3
T3.5@120mhz    784.7   1947.9   1079.8    Faster    v1.1.0
T3.5@120mhz    658.5   1577.9    919.5    Faster    v1.5.3
K64F@120mhz    635.7   1273.8    827.2    ARM GCC -O3   arm_math.h v1.4.5
T3.2@120mhz    869.8   2498.5  18182.5    Faster   v1.1.0
adaM4F@120mhz  701.3   1756.1    781.0    Faster   v1.1.0   SAMD51
STM32L4@80mhz  917.3   1953.8   1150.4    Faster   v1.4.5
STM32F405@168  466.5   1135.1    556.1    -O2      v1.6.0
F767ZI@216mhz  206.9    352.7    262.7    arm gcc -O3  v1.5.1

Floating-point intensive Kalman filter update
Code:
Kalman filter update time
                 microseconds
    T4@600mhz         80
    M7@600mhz         99
  T3.6@256mhz        176
  T3.6@180mhz        248
  T3.5@120mhz        351
  T3.2@120mhz       3396
  ESP32@240mhz       220
  adaM4F@120mhz      361
  STM32L4@80mhz      535
  STM32F405@168mhz   225
  F446RE@180mhz      290
  F767ZI@216mhz      253
  1170@996mhz         96
  mega2560@16mhz   30272

Code:
 float math lib (trig) lat,lon to UTM
                 microseconds
    T4@600mhz          4.2
    M7@600mhz          5
  T3.6@180mhz         27
  T3.5@120mhz         39
  T3.2@120mhz        448
  1170@996mhz          5
  ESP32@240mhz        33
  adaM4F@120mhz       35
  STM32L4@80mhz       60
  STM32F405@168mhz    22
  F767ZI@216mhz       14
  mega2560@16mhz    3408

Code:
 raytrace 8x8 float  -O2
                 microseconds
  1170@996mhz         28960   NXP SDK -O3
  T4@600mhz           45372
  T3.6@180mhz        186409
  T3.5@120mhz        301454
  T3.2@120mhz       6634437   no FPU
  ESP32@240mhz       204252
  adaM4F@120mhz      328686
  STM32F405@168mhz   225093
  F767ZI@216mhz      134194   -O3
  STM32L4@80mhz      546230

Code:
  finite difference 51x21 float -O2
                 microseconds
    T4@600mhz         42305     double 84134 
  T3.6@180mhz        169559          3662799
  T3.5@120mhz        257085
  T3.2@120mhz       4541625     no FPU
  1170@996mhz         24672
  ESP32@240mhz       521806
  adaM4F@120mhz      250132
  STM32F405@168mhz   179313
  F767ZI@216mhz      130689
  STM32L4@80mhz      424934

Code:
           float interpolate (us)  8x8 to 70x70
               bilinear  bicubic
T3.2@120mhz      18773    223109
T3.5@120mhz       1944     26618
T3.6@180mhz       1294     16712
T4@600mhz          255      6406
1170@996mhz        158      2048   SDK -O3
adaM4F@120        1905    207326
ESP32@240mhz      1983    114813
STM32L4@80mhz     2897     37962
STM32F405@168mhz  1356    157633   -O2
F767ZI@216mhz       875    20149   -O3

Code:
mandelbrot   (mops)
                   float  double
    T4@600mhz      230.1   119.3
  T3.6@180mhz       80.4     2.4
  T3.5@120mhz       49.5     1.1
  T3.2@120mhz        1.2     0.8
  1170@996mhz      319     192
  ESP32@240mhz      82.8     2.9
  adaM4F@120mhz     42.9     1.6
  STM32L4@80mhz     32.2     0.9
  STM32F405@168mhz  65.4     2.1
  F767ZI@216mhz     85.1    34.4

Code:
whetstone   (MIPS)
                   float  doubletrig
    T4@600mhz     1694.9  1351.4
    M7@600mhz      939.7   543.6   NXP 1062 SDK
    M7@600mhz     1123.6   510.2   NXP 1052 mbed
  T3.6@180mhz      438.6    34.6
  T3.5@120mhz      189.4    16.2
  T3.2@120mhz       20.9    13.0
  1170@996mhz     1789     600
  ESP32@240mhz     187.2    44.6
  adaM4F@120mhz     90.8    12.3
  STM32L4@80mhz     48.4     6.4
  STM32F405@168mhz 163.0    28.9
  F767ZI@216mhz    380.2   182.2
whetbar.png

Cortex-M7 instruction cycle counts, timings, and dual-issue combinations (superscalar Teensy 4 and NXP 1170))
https://www.quinapalus.com/cm7cycles.html
 
Last edited:
Happy New Year also from my side.

Trying to understand the generation of I2S_MCLK
(new terminology and too many options makes live somewhat difficult (without 1 GHz logic analyser, have only 250 MHz on single channel), so must work displaying bit-clock)
 
Bottom side (smt) and right side (through hole) pads:

Your pin table seems to suggest I can get to pin 30 (for GPT PPS test) from the top side with one of the through-hole pads ... which pad? Or does that just refer to the end holes for VBAT etc.

Could i use XBAR to route pin 30 to another edge pin? (I haven't really figured out XBAR yet)

thanks and Happy New Year
 
Last edited:
I've updated FastCRC - compiles without hardwaresupport, and tables instead. Same for __SAM3X8E__
@Paul, please update the lib :)


Edit: Where can I find a list which shows which targets
a) need #include <avr/pgmspace.h>
b) need #include <pgmspace.h>
c) don't want it
??
 
I ran stock FastCRC (using 16K buffer)
Code:
     CRC Benchmark
     F_CPU: 396 MHz, length: 16384 Bytes.   really 600 mhz
     Maxim (iButton) FastCRC:   Value:0xF6, Time: 200 us (655.36 mbs)
     Maxim (iButton) builtin:   Value:0xF6, Time: 1200 us (109.23 mbs)
     MODBUS FastCRC:    Value:0x7029, Time: 330 us (397.19 mbs)
     MODBUS builtin:    Value:0x7029, Time: 1580 us (82.96 mbs)
     XMODEM FastCRC:    Value:0x98D9, Time: 450 us (291.27 mbs)
     XMODEM builtin:    Value:0x98D9, Time: 1890 us (69.35 mbs)
     MCRF4XX FastCRC:   Value:0x4A29, Time: 330 us (397.19 mbs)
     MCRF4XX builtin:   Value:0x4A29, Time: 270 us (485.45 mbs)
     KERMIT FastCRC:    Value:0xB259, Time: 80 us (1638.40 mbs)
     Ethernet FastCRC:  Value:0x1271457F, Time: 700 us (187.25 mbs)
T4 compile of FastCRC benchmark doesn't find util/crc16.h, so i copied crc16.h into the lib folder to get it to compile.
I had also tested FastCRC (table-driven) on EVKB eval board, see EVKB tests. T4 has a hardware CRC32 (fixed poly), i did some testing on the EVKB board (crc32 16384 bytes 183 us 716.24 mbs (90 MBs))

EDIT: implemented hardware CRC32 (part of DCP) on T4 beta, 381 MBs for 16K buffer. See post #1600
 
Last edited:
Paul i've used #if defined(__IMXRT1052__) || defined(__IMXRT1060__) - is that ok for other libs, too? Or will there be a more general __IMXRT__ ? - additional?
 
Found my many years old interrupt-tester which was used to test if unused interrupts work.
They work on IMXRT, too :)
Code:
#define NVIC_STIR           (*(volatile uint32_t *)0xE000EF00)
#define NVIC_TRIGGER_INTERRUPT(x)  NVIC_STIR=(x);

volatile int chk;

void softISR() {
  chk = 1;
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  Serial.println("...OK.");
}
#if 0
//const unsigned char swInterrupts[] = {33,39,44,53,54,55,56,57,58,59,67,68,69,70,71,72,91,92,93,94,95,96,98,102,108,109,IRQ_SOFTWARE+16/*,IRQ_SOFTWARE+17*/,0};
#else
 const unsigned char swInterrupts[] = {IRQ_Reserved1, IRQ_Reserved2, IRQ_Reserved3, IRQ_Reserved5, IRQ_Reserved6, IRQ_Reserved9, IRQ_Reserved10,  IRQ_Reserved13, 0};
#endif


void setup() {
  delay(600);
  pinMode(LED_BUILTIN, OUTPUT);  
  Serial.println("Reserved Interrupt tester");
  unsigned char n = 0;  
  while (swInterrupts[n] > 0) {    
    int interrupt = swInterrupts[n];
    Serial.printf("%d (%d)",interrupt, interrupt - 16);
    _VectorsRam[interrupt] = softISR;    
      NVIC_ENABLE_IRQ(interrupt - 16);                        
    chk = 0;
    //Trigger swi this way :    
    // NVIC_SET_PENDING(interrupt - 16);
    //Or this way (faster):
    NVIC_TRIGGER_INTERRUPT(interrupt - 16);
    delay(50);
    if (!chk) Serial.println("...NOT OK.");    
    n++;
  }
  
  Serial.println("Done.");
  while(1){;}  
}

void loop() {}
It also shows, that NVIC_SET_PENDING and NVIC_TRIGGER_INTERRUPT are working.
As you see in the list, some "reserved" numbers are missing - shall I rename them? IRQ_SOFTWARE is missing, too. I'd use the last, IRQ_Reserved13.
 
Here's a hack sketch for "attachInterrupt" for T4 pin 12 (GPIO B0_01 on GPIO2). Teensy 3 attachInterrupt has macros for generating ISRs with function table ... more study rerquired

Code:
// GPS PPS on pin 12  GPIO2 1  B0_01
#include "Arduino.h"

volatile uint32_t ticks;
void pinisr() {
  GPIO2_ISR |= 1 << 1; // clear interrupt
  ticks++;
  while (GPIO2_ISR & (1 << 1)); // wait for clear
}

void setup() {
  Serial.begin(9600);
  while (!Serial);
  delay(3000);
  Serial.println("starting");
  pinMode(12, INPUT);
  GPIO2_ICR1 |= 2 << 2; // rising on pin 1
  GPIO2_EDGE_SEL = 0;  // not both

  attachInterruptVector(IRQ_GPI02_0_15, pinisr);
  NVIC_ENABLE_IRQ(IRQ_GPI02_0_15);
  GPIO2_ISR |= 1 << 1; // clear interrupt
  GPIO2_IMR |= 1 << 1; // pin 1 interrupt enable
}

void loop() {
  static uint32_t prev = 0;
  if (ticks != prev) {
    Serial.println(ticks);
    prev = ticks;
  }
}
Having micros() resolution at only 10 us is also messing up my GPS PPS sketches

EDIT: corrected the sketch above to wait for interrupt pin to clear.
 
Last edited:
did following code to set to set SAI1 MCLK
Code:
#include "Arduino.h"

// this should be corrected in imxrt.h (from 1F to 3F)
#define CCM_CS1CDR_SAI3_CLK_PODF(n)		((uint32_t)(((n) & 0x3F) << 16))
#define CCM_CS1CDR_SAI1_CLK_PODF(n)		((uint32_t)(((n) & 0x3F) << 0))

// this should go into imxrt.h
//
#define CCM_ANALOG_PLL_AUDIO_POST_DIV_SELECT(n) ((uint32_t)(((n) & 0x03)<<19)) 
#define CCM_ANALOG_PLL_AUDIO_BYPASS ((uint32_t)(1<<16)) 
#define CCM_ANALOG_PLL_AUDIO_BYPASS_CLK_SRC(n) ((uint32_t)(((n) & 0x03)<<14)) 
#define CCM_ANALOG_PLL_AUDIO_ENABLE ((uint32_t)(1<<13)) 
#define CCM_ANALOG_PLL_AUDIO_POWERDOWN ((uint32_t)(1<<12)) 
#define CCM_ANALOG_PLL_AUDIO_DIV_SELECT(n) ((uint32_t)((n) & ((1<<7)-1))) 

#define CCM_ANALOG_MISC2_DIV_MSB (1u<<23)
#define CCM_ANALOG_MISC2_DIV_LSB (1u<<15)

#define CCM_ANALOG_PLL_AUDIO_NUM_MASK ((uint32_t)((1<30)-1))
#define CCM_ANALOG_PLL_AUDIO_DENOM_MASK ((uint32_t)((1<30)-1))

#define CCM_CSCMR1_SAI1_CLK_SEL_MASK (CCM_CSCMR1_SAI1_CLK_SEL(0x03))
#define CCM_CS1CDR_SAI1_CLK_PRED_MASK (CCM_CS1CDR_SAI1_CLK_PRED(0x07))
#define CCM_CS1CDR_SAI1_CLK_PODF_MASK (CCM_CS1CDR_SAI1_CLK_PODF(0x3f))

#define CCM_CSCMR1_SAI2_CLK_SEL_MASK (CCM_CSCMR1_SAI2_CLK_SEL(0x03))
#define CCM_CS2CDR_SAI2_CLK_PRED_MASK (CCM_CS2CDR_SAI2_CLK_PRED(0x07))
#define CCM_CS2CDR_SAI2_CLK_PODF_MASK (CCM_CS2CDR_SAI2_CLK_PODF(0x3f))

#define CCM_CSCMR1_SAI3_CLK_SEL_MASK (CCM_CSCMR1_SAI3_CLK_SEL(0x03))
#define CCM_CS1CDR_SAI3_CLK_PRED_MASK (CCM_CS1CDR_SAI3_CLK_PRED(0x07))
#define CCM_CS1CDR_SAI3_CLK_PODF_MASK (CCM_CS1CDR_SAI3_CLK_PODF(0x3f))

/*
* 
*/
void set_audioClock(int nfact = 27, int32_t mult=0, uint32_t div=1)
{ 
  CCM_ANALOG_PLL_AUDIO = 0;
  //CCM_ANALOG_PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_BYPASS;
  CCM_ANALOG_PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_ENABLE;
  CCM_ANALOG_PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_POST_DIV_SELECT(2); // 0: 1/4; 1: 1/2; 0: 1/1
  CCM_ANALOG_PLL_AUDIO |= CCM_ANALOG_PLL_AUDIO_DIV_SELECT(nfact);    
  
  CCM_ANALOG_PLL_AUDIO_NUM   = mult & CCM_ANALOG_PLL_AUDIO_NUM_MASK;
  CCM_ANALOG_PLL_AUDIO_DENOM = div  & CCM_ANALOG_PLL_AUDIO_NUM_MASK;
  
  const int div_post_pll = 1; // other values: 2,4
  CCM_ANALOG_MISC2 &= ~(CCM_ANALOG_MISC2_DIV_MSB | CCM_ANALOG_MISC2_DIV_LSB);
  if(div_post_pll>1)
    CCM_ANALOG_MISC2 |= CCM_ANALOG_MISC2_DIV_LSB;
  if(div_post_pll>3)
    CCM_ANALOG_MISC2 |= CCM_ANALOG_MISC2_DIV_MSB;
}

void sai1_setClock(int n1, int n2) 
{ 
  CCM_CCGR5 |= CCM_CCGR5_SAI1(CCM_CCGR_ON);
  IOMUXC_GPR_GPR1 |= (IOMUXC_GPR_GPR1_SAI1_MCLK_DIR | IOMUXC_GPR_GPR1_SAI1_MCLK1_SEL(0));

  // clear SAI1_CLK register locations
  CCM_CSCMR1 &= ~(CCM_CSCMR1_SAI1_CLK_SEL_MASK);
  CCM_CS1CDR &= ~(CCM_CS1CDR_SAI1_CLK_PRED_MASK | CCM_CS1CDR_SAI1_CLK_PODF_MASK);
  //
  CCM_CSCMR1 |= CCM_CSCMR1_SAI1_CLK_SEL(2); // &0x03 // (0,1,2): PLL3PFD0, PLL5, PLL4,  
  CCM_CS1CDR |= CCM_CS1CDR_SAI1_CLK_PRED(n1-1); // &0x07
  CCM_CS1CDR |= CCM_CS1CDR_SAI1_CLK_PODF(n2-1); // &0x3f   

}

void sai1_configurePorts(int iconf=0)
{
  CORE_PIN23_CONFIG = 3;  //1:MCLK
  CORE_PIN21_CONFIG = 3;  //1:RX_BITCLK
  CORE_PIN20_CONFIG = 3;  //1:RX_FS
  CORE_PIN7_CONFIG  = 3;  //1:RX_DATA0
  CORE_PIN8_CONFIG  = 3;  //1:RX_DATA1
  CORE_PIN9_CONFIG  = 3;  //1:RX_DATA2
  CORE_PIN32_CONFIG = 3;  //1:RX_DATA3
}

extern "C" void setup() {
  // put your setup code here, to run once:
  delay(1000);
  Serial.println("T4_test");

  sai1_configurePorts();

  int fs = 192000;
  int fs_mclk = fs*256; // 49.152 MHz 
  int c0, c1, c2;
  int n1, n2;

  n1 = 4; // to ensure that input to last divisor (i.e. n2) is < 300 MHz
  n2 = 4;

  // e.g. 49.152 = 32.768*24 / (n1*n2)
  c0 = 32;  
  c1 = 768;
  c2 = 1000;
  // Note: c0+c1/c2 must be between 27 and 54 ()

  set_audioClock(c0,c1,c2);
  sai1_setClock(n1,n2);

  pinMode(LED_BUILTIN, OUTPUT);
}

extern "C" void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}

(used from main.cpp, therefore extern "C")

problem encountered was that before setting dividers the fields must be erased. (obviously in hindsight)
not sure what the future API of setting PLL's clock speed is, I simply provide a sketch as example.
two macros in imxrt.h are slightly off (pull request submitted) and others are missing.
 
Last edited:
@manitou -
Guess I can't sleep - too much goes on when I wake up :)
dsp.zip contains files to support M7 DSP (arm_math.h v1.5.1) on Teensy 4. I tested with a DSP benchmark.
Thanks for the files. By the way I tried running the CMSIS Neural Network library but it needed two additional files:
Code:
arm_const_structs.h
arm_common_tables.h
I just copied these from the main cmsis GitHub page but not sure it they are correct for your version.

The sketch I used to test CMSIS-NN ran one time. Made a minor change to get timing when I reloaded wound up loosing the USB - had to reload a different sketch and tap the button once to get it to recognize the usb port on windows again. Related to USB issue or something else now 100% sure.

EDIT: If you want to give it a try: https://github.com/mjs513/CMSIS-NN--Neural-Network--for-Teensy-3.6. Just copy the CMSIS-NN to your library folder
 
Last edited:
Happy New Year!

I now have a version of HardwareSerial that is working with buffering data and using ISR to output :D

Not saying it is perfect yet. Right now trying to enable more parts of my branch to get Serial1.read()... stuff to work as well.

With the SerialX output code, I am trying to uncomment the code that is to handle the inverted Interrupt priority issue. That is Serial1.write() is called and Buffer is full, and the code is running at a higher priority than the HardwareSerial Interrupt, so to not hang, the loop puts the data output...

Current problem is that the function: nvic_execution_priority
We used for Teensy 3.x is not defined...

Also currently I have hard coded the interrupt priority as one #define in HardwareSerial.cpp. Will probably do like my other branch and put a field into the hardware structure, so each Serial object can have their own priority...

But if anyone wishes to play along, the code is up at: https://github.com/KurtE/cores/tree/Teensy4_HardwareSerial
Only need HardwareSerial.h and .cpp...

Hopefully more parts working later today
 
EDIT: I made a first attempt at fixing C++ constructors. Here's the commit on github.

https://github.com/PaulStoffregen/cores/commit/4d620d12cd3dd72d7963d2e3d14c9141369b3de1

So far only did a quick test with this code.

Code:
#include "debug/printf.h"

class myclass {
  public:
  myclass() {
    printf("myclass constructor\n");
  }
  void test() {
    printf("myclass test\n");
  }
};

myclass myinst;

void setup() {
  myinst.test();
}

void loop() {
  digitalWrite(3, HIGH);
  delay(1500);
  digitalWrite(3, LOW);
  delay(1500);
}


@Kurt - Do you have any quick test cases handy for the constructor & vtable issues? Going to take a break for a few hours - then look at that issue later today and make a beta5 installer when it's fixed. A couple small test cases would save me a little time if you have any ready to go.
 
Last edited:
@PaulStoffregen
Was testing your attachinterrupt addition but the MPU9250 sketch I use, happens to use class constructors, etc. Before your class constructor fix it would loose the usb consistently. After, both class constructors work as well as attaching interrupt. I used pin 1. Going to test with the BME280 library just as a double and will post the update here.

Oh for anyone pulling the attachinterrupt update, don't forgot to update your imxrt.h file as well :)

Just thought you like to know.

UPDATE: Just tested the BME280 library and the constructor again works that was causing issues yesterday.
 
Last edited:
Hi Paul,
I think this one should do it... That is this one would fault until I made constructor to be const... Also my hardware Serial...
This should have the code in place that at the start dumps the variable so you can see it was all 0's...

Code:
class TestSerial : public Stream {
  public:
    TestSerial() {state_ = 0;};
    virtual int available(void);
    virtual int peek(void);
    virtual void flush(void);
    virtual size_t write(uint8_t c);
    virtual int read(void);
    using Print::write;
    size_t nonVirtualfunc(uint8_t c);
    uint8_t state_;
};

int TestSerial::available(void) {return 0;}
int TestSerial::peek(void){return 0;}
void TestSerial::flush(void) {return;}

size_t TestSerial::write(uint8_t c) {
  digitalWrite(3, HIGH);
  state_ = state_? 0 : 1;
 digitalWrite(13, state_);
 digitalWrite(3, LOW);
 return 0;  
}

size_t TestSerial::nonVirtualfunc(uint8_t c) {
  digitalWrite(3, HIGH);
  state_ = state_? 0 : 1;
 digitalWrite(13, state_);
 delay(100);
 digitalWrite(3, LOW);
 return 0;  
}

int TestSerial::read(void){return 0;}

TestSerial ts;

void setup() {
  while ( !Serial && millis() < 600 ) {
    if ( 0 == ARM_DWT_CYCCNT &&  0 == ARM_DWT_CYCCNT ) {
      digitalWrite(LED_BUILTIN, HIGH);
  //    SOME_SERIAL.println( "   ARM_DEMCR_TRCENA done!" );
      ARM_DEMCR |= ARM_DEMCR_TRCENA;
      // ARM_DWT_CTRL |= ARM_DWT_CTRL_CYCCNTENA; // turn on cycle counter << THIS LINE NOT NEEDED
    }
  }
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  Serial.println("Test begun");
  uint16_t cb = sizeof(TestSerial);
  Serial.printf("Test Serial: %x Size:%d ", (uint32_t)&ts, cb);
  uint8_t *b = (uint8_t*)&ts;
  while (cb--)Serial.printf("%x ", *b++);
  Serial.println();

  // Now lets try Serial
  cb = sizeof(Serial);
  Serial.printf("Serial: %x Size:%d ", (uint32_t)&Serial, cb);
  b = (uint8_t*)&Serial;
  while (cb--)Serial.printf("%x ", *b++);
  Serial.println();

  // Now lets try Serial1
  cb = sizeof(Serial1);
  Serial.printf("Serial1: %x Size:%d ", (uint32_t)&Serial1, cb);
  b = (uint8_t*)&Serial1;
  while (cb--)Serial.printf("%x ", *b++);
  Serial.println();

  
  // put your setup code here, to run once:
  pinMode(13, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);

  for (uint8_t i=0; i< 5; i++) {
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    delay(250);
  }
  
}
uint8_t buf[]={0,1};
void loop() {
  digitalWrite(2, HIGH);
  //ts.write((uint8_t)0x00);  // see if we call through the virtual function
  ts.write(buf, 1);
  //ts.nonVirtualfunc(0);
  digitalWrite(2, LOW);
  delay(500);
}
 
I'm running that now. Here's what I get in the serial monitor. Does this look ok? (sorry... have only a few min before I have to leave)

Code:
/tmp/arduino_modified_sketch_321946/sketch_jan01a.ino Jan  1 2019 07:56:11
Test begun
Test Serial: 2000201c Size:16 8 0 0 20 0 0 0 0 e8 3 0 0 0 0 0 0 
Serial: 20000a94 Size:16 3c 5 0 20 0 0 0 0 e8 3 0 0 0 0 0 0 
Serial1: 200009d0 Size:24 d0 0 0 20 0 0 0 0 e8 3 0 0 0 0 0 0 0 80 19 40 58 12 0 60

I'm about to package up beta5. Even if this isn't perfect, maybe a step in the right direction?
 
Status
Not open for further replies.
Back
Top