Teensy-LC Beta Testing

My Teensy-LC has arrived, thank you. Blinky lights, the lot.

I note that usb-midi has not yet been tested, neither has direct MIDI ports. I will test both (hopefully, assuming i can find my old joystick to midi lead), along with multiple trellis' (4 pieces) over i2c. I also have an adafruit PCA9685 16 Channel 12bit PWM/Servo driver which I'll try and fire up once i've done that.
 
PaulStoffregen;64029 I've uploaded version [URL="https://forum.pjrc.com/threads/27689-Teensy-LC-Beta-Testing" said:
1.21-test4[/URL], with everything done so far, and the serial monitor bugs (hopefully) fixed.

the two serial monitor problems I had:
1) (MD5) initial messages in setup() often would not show, even with while(!Serial)
2) linpack high speed output, no scroll --> froze IDE

seem to be FIXED with 1.21-test4 (1.0.6 on ubuntu). yeah.
 
ledRings library with Mayhew labs LED ring and encoder seems to be working on LC

earlier 3.1 thread: https://forum.pjrc.com/threads/25917-Teensy-3-1-and-Meyhew-Led-Rings-Library

Also tested Servo library, sweep example worked.

Entropy lib worked. collected 1 MB random data. data passed randomness tests.

pulseIn worked, though you need pinMode(n,INPUT) for pulseIn (don't need that for Arduino). tested with PWM out from another pin. compared with measuring pulse width with attachInterrupt() (also
requires pinMode(n,INPUT) for interrupt pin (don't need pinMode for Arduino). both methods showed no jitter. (conceivably, pulseIn might measure extra delay from millis timer interrupt or USB interrupts ?)

added DMA ISR to memcpy32() test (DMA memcpy), DMA ISR worked

GPS with Time library, examples>time>TimeGPS worked (Serial1)

?? TinyGPS lib when i load test_with_gps_device example into the IDE, i get two tabs (two copies), which the compiler doesn't like. I deleted all the lines in one of the tabs, and then it compiled and worked with Serial1. I've never seen that before ?? 1.0.6/1.21-test4 (I have test3/1.0.5 on another machine, the TinyGPS examples look fine in the IDE)
Edit: examples directories have both a .ino AND a .pde FIXME
 
Last edited:
Got my LC - I'll be testing the USB-MIDI library, as well as possibly testing an ILI9341 over parallel 8bit connection, and probably a number of other things!

Blinky and USB uploaded work as expected.
 
Last edited:
There was a post in another thread asking about the Adafruit_Neopixel library and the LC.

I just tested it and everything works with no issues using WS2812Bs on the data pin 17@5V, at 48 Mhz.

At 24 Mhz I get this compile error:

Code:
#error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz

edit -- I checked the library and this is coming from the library -- Adafruit_Neopixel.cpp line 823, my guess is this is Paul's assembler code. I doubt it's a real problem; I can't think of any realistic scenario where you'd be using power hungry WS2812 LEDs but try to save some juice by slowing down the MCU.
 
Last edited:
Hi Paul,

I can confirm, that IRQ_SOFTWARE works, and in addition IRQ 4 too (can be used as SWI)

The register NVIC_STIR does not exist, so the calling SWI with NVIC_STIR does not work.

Regards, Frank

Code:
//LC-Interrupt test

//NVIC_STIR does not exist with Teensy-LC
//#define NVIC_STIR		   (*(volatile uint32_t *)0xE000EF00)
//#define NVIC_TRIGGER_INTERRUPT(x)  NVIC_STIR=(x);


void setup() {
  delay(1000);
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  while (!Serial) {;}
}


volatile int chk;

void softISR() {
  chk = 1;
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  Serial.println("...OK.");
}

const unsigned char swInterrupts[] = {1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,/*24,*/25,26,27,28,IRQ_SOFTWARE,30,31,0};

void loop() {    
  Serial.println("Reserved Interrupt tester");
  unsigned char n = 0;  
  while (swInterrupts[n] > 0) {    
    int interrupt = swInterrupts[n]+16;
    Serial.printf("%d (%d)",interrupt, interrupt - 16);
    _VectorsRam[interrupt] = softISR;    
    NVIC_ENABLE_IRQ(interrupt - 16);                        
    chk = 0;
     NVIC_SET_PENDING(interrupt - 16);
    delay(50);
    if (!chk) Serial.println("...NOT OK.");    
    n++;
  }
  
  Serial.println("Done.");
  while(1){;}
}

The official unused RTC gives us some more free interrupts (20 + 21).
 
Last edited:
At 24 Mhz I get this compile error:

Yeah, that's my fault. I spent an entire day writing those 64 lines of asm code. By the time it was finally working and tuned nicely with a great-looking waveform on my scope, I just didn't have the energy left to parameterize the delays or tune a 2nd copy. Instead, I added the #error message, and then Robin & I went out for dinner with the couple remaining hours that evening.
 
paul, take a look at reply #53 in this thread, IDE strangeness with TinyGPS ?

Edit: OK, the examples directories have both a .pde and a .ino ...
 
Last edited:
FASTRUN works:

Code:
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}

FASTRUN __attribute__((no_inline)) void blink(void){
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}

void loop() {    
 blink();
 delay(200);
}
 
Edit: let's at least try single ended vs differential mode, both settings for the a/b mux, and try reading the other unused channels with all 4 combinations of mode & ab mux. Let's also make sure the comparator and dac are powered up, just in case. If none of that works, I'll ping Freescale. But functionality-related silicon bugs almost never get fixed, so unless there's some undocumented trick to enable it, if we can't find a way to access it, odds are it's simply not there.

I tried 64+26 in channel2sc1a[] for temp sensor. I think that was working, though way off from my calibration equation, but values changed as i held my finger on MCU ... I didn't have such luck finding the bandgap ...

i don't know how to set "a/b mux"?
 
Last edited:
I've been going through my components and testing against the LC. So far the only problem I've found is with FastLED.

SPI - TLC5916, CC3000, Micron M25P40 and M25PE40 Flash chips, LC as SPI master + Arduino as SPI slave using Nick Gammon's SPI slave example

I2C - DS3231 RTC, Freescale MPR121 touch sensor, Atmel QT1070 touch sensor, Semtech SX9510 touch sensor

Serial1 - echo tests with FT230x @ 1MBaud, Teensy 3.1 @ 1MBaud, Raspberry Pi @ 230Kbps

I'm going to test the touch pins now. I had hoped to start experimenting with the LC + ESP8266 WiFi module but apparently I'm out of 3V3 regulators so that will have to wait for a few days until Digikey can fix that.

[*] Some libraries, such as the QT1070 at https://github.com/scjurgen/AT42QT1070, are pretty old and hardcoded for the Mega328's interrupts 0 on pin 2 and 1 on pin 3. They need to be changed to use the Teensy LC's 1:1 interrupt to pin mapping (but the same change is needed for any non Mega328 board).

FastLED examples fail with:

Code:
In file included from Z:\Documents\Arduino\libraries\FastLED/clockless.h:22:0,
                 from Z:\Documents\Arduino\libraries\FastLED/FastLED.h:32,
                 from Cylon.ino:1:
Z:\Documents\Arduino\libraries\FastLED/clockless_trinket.h: In function 'void _dc_AVR(uint8_t&) [with int _LOOP = 2; int PAD = 1; uint8_t = unsigned char]':
Z:\Documents\Arduino\libraries\FastLED/clockless_trinket.h:29:58: error: impossible constraint in 'asm'
        [loopvar] "+a" (loopvar) : [_LOOP] "M" (_LOOP) : );
                                                          ^

The same code compiles fine with Teensy 3.x as the target so my guess is it just needs to be updated for the new ARM chip like Adafruit_Neopixel was. I believe I saw in another thread that one of the authors is in the next beta test round so I will not pursue this further unless someone wants me to.
 
I believe Daniel Garcia is due to get his Teensy-LC early next week. He was already working on optimized SPI code based on the datasheet, so I'm pretty sure we'll be seeing very good things happening soon with FastLED.
 
I believe Daniel Garcia is due to get his Teensy-LC early next week. He was already working on optimized SPI code based on the datasheet, so I'm pretty sure we'll be seeing very good things happening soon with FastLED.

I've currently got a local branch with most of FastLED building and running on there. Working on the support for WS2812/TM1809/LPD1886/etc... now. The lack of a clock cycle accurate counter is proving to be a pain/problem however. I can't seem to get the FTM clocks to run at higher than 24Mhz - if I do something like say:

Code:
void loop() {
	cli();
	FTM2_SC = FTM_SC_PS(0) | FTM_SC_CLKS(1);
	FTM2_CONF = 0;
	FTM2_MOD = 60;
	FTM2_CNT = 0;
	FTM2_STATUS = 0x1FF; // clear all the status bits

	int cnt = 10;

	do {
		while(!(FTM2_STATUS & 0x100)); // wait until overflow
		FTM2_CNT = 0;
		GPIOB_PSOR = (1<<17);
		FTM2_STATUS = 0x1FF;
		while(!(FTM2_STATUS & 0x100)); // wait until overflow
		FTM2_CNT = 0;
		GPIOB_PCOR = (1<<17);
		FTM2_STATUS = 0x1FF;
	} while(cnt--);
	sei();
}

My pin toggles every 2.88µs, or 138 clocks. If I set FTM2_MOD to 120 then it toggles every 5.38µs or 258 clocks. So that counter is running closer to 24Mhz than 48Mhz. It looks like looping on the FTM2_STATUS register ends up costing me close to 20 clocks (time spent reading FTM2_STATUS? or time in the loop? The disassembly doesn't look too terrible). I wasn't running into these kinds of overhead with the DWT_CYCCNT register on the teensy 3.1. Since I've got about a dozen chipsets like this with different timings, hand counting out nop loops for each isn't an option I'd really like to chase down. (I do have some other things to fallback on - but being able to do the timings off of a clock/timer on the due & the teensy's K20s has been really useful/nice).

The SPI code isn't as optimized as I'd like yet - need to do some more work with it, but it's getting there - and is definitely working/workable.

Going back to the reference manual to see if there's anything better I can pull out of there to use, timing-wise.
 
I just verified that the nRF224L01+ works well using ManiacBug's library on Teensy LC. I naively switched the SPI port to MOSI1, MISO1, SCK1, and CS1 but I am not getting a response. Do I have to do something special to enable SPI1 if SPi0 is the default?
 
Is there anything left i could test ? :)

Could you look at SPI.transfer(buffer, len) and SPI.transfer16(n) ?

I've been updating the list on the first message of this thread. Lots of things on the list still have blank lines, meaning no testing has been done (or I missed the message and didn't update the list).
 
It's not on the list, but I'm sure you'll be pleased to know that a four trellis set works just fine, with four i2C devices, and no modification at all (Except changing the intpin used by the example file.)

Not tested in anger but all the lights ping on and off both via the code and the buttons.

IMG_8898.jpg
 
Could you look at SPI.transfer(buffer, len) and SPI.transfer16(n) ?

I've been updating the list on the first message of this thread. Lots of things on the list still have blank lines, meaning no testing has been done (or I missed the message and didn't update the list).

I'll check out SPI.transfer() if Frank B can't get it it.

But I just noticed blanks on EEPROM and random so I just tested those, and both run fine -- one program randomSeed(0) and EEPROM.write(0..127, random(256)), another program randomSeed(0) and compare random(256) against EEPROM.read(0..127)
 
12 MHz for SP0, and 24 MHz for SPI1

OK, I know cut-and-paste is no substitute for knowledge, but I measure only 12 mhz (logic analyzer) for SPI1 CLK out of this low-level SPI1 sketch (cobbled from fastLED code). Is there some other register I need to tweek to double clock source ??? I like to measure "guaranteed not to exceed" parameters.

Edit: OOOPS pilot error, (running LC at 24mhz), at 48 MHZ, analyzer shows SPI1 CLK at 24 mhz.
Reported speed of transfer is 11.9 mbs using spi1_transfer() function in sketch on github.

Edit: SPI1 testing sketch (hack) is at
https://github.com/manitou48/teensy3/blob/master/spi1perf.ino


Edit: measured transmit-only speed on SPI1 at 19.9 mbs for 1000 byte transfer using the writeBytes() function in the sketch above. Also measured speed of 16-bit transfer using write16s()


LC beta SPI1 performance summary (write 1000 bytes or 500 shorts)
Code:
               SPI      16-bit   DMA-8
SPI1 clock    write     write    write   MODE1
4MHz          3.6 mbs    3.8       3.6     3.9
8MHz          7.1 mbs    7.5       7.1     7.9
12MHz        10.6 mbs   11.2      10.6    11.9
24MHz        19.9 mbs   22.3      21.0    23.5
  (max SPI0 clock is 12MHz. MODE1 faster than MODE0)

Added FIFO test to sketch. 8-bit FIFO performance same as writeBytes()


(SPI performance for other MCUs: https://github.com/manitou48/DUEZoo/blob/master/SPIperf.txt )
 
Last edited:
Back
Top