Teensy LC startup time

Status
Not open for further replies.

profor

Active member
Hello,

i would like to ask, how fast the Teensy LC will "boot"?

I would like to replace Arduino MINI PRO which i programmed without bootloader to get as fast as possible startup operation.
I am working on turn signal replacement for my car where will be 9 LEDs and i want to make effect as new Audi has, that the turnsignal does not light whole, but comming from center of the car to its side.

The housing i already have, there are reflectors for 9 leds:)

On MINI i decided to use software pwm since it has only 6 HW PWM ports, now i see on LC is 10 which is great so i would be able to control each LED separately (fade in).

With MINI i was able to light up first LED around 10ms from powering the whole turnsignal on.

Can anyone tell or try with oscilloscope or logic analyzer to do just digitalWrite and measure the time?
I have Teensy 3.1 but it might be different so i did not try to measure that time.

Thank You from Slovakia.
Dusan
 
The answer is: approx 5.2 milliseconds.

file.png
(click for full size)

The yellow trace is VIN, green is the 3.3V power, and blue is pin 13. The Teensy-LC was running File > Examples > 01.Basics > Blink.

Most of that 5.2ms startup time is probably this 4ms delay:

https://github.com/PaulStoffregen/cores/blob/master/teensy3/pins_teensy.c#L477

If you need even faster startup, you could try deleting that line from the core library.
 
If you need *really* fast startup behavior, you could try editing mk20dx128.c. That code runs before the crystal is oscillating! You'll need to be very careful with the programming, since it's before the C runtime is initialized and and C++ objects are constructed, so only the most direct hardware register level programming is possible. Normal Arduino functions can't work in that file. But it does allow you to control the hardware very early in the startup process, even before the crystal is oscillating!
 
One other startup behavior, which may or may not be of any concern to you, but I'll mention in case you or anyone who finds this thread later might care... is regarding the ADC calibration.

At startup, the ADC begins an internal calibration process. If you call analogRead() before the calibration has completed, the first measurement is delayed. Likewise, if you change the analog reference, a new calibration is started.

You asked only for the delay from power up to digitalWrite. If you also care about analogRead, expect a short delay for the first measurement. AVR has a similar behavior, where the first time the ADC is read, it takes approximately twice as long while the hardware does internal setup.
 
Teensy 3.1

Hello Paul,
i confirm on Teensy 3.1 5,27ms - this is without modification of 4ms delay as Paul pointed out earlier

Teensy3.1_4ms.jpg
 
Last edited:
I modified the 4ms delay to 1ms and digital write was "faster"

Interesting is that analogWrite take more time.

Code:
void loop() {
  analogWrite(led8, 200);
  digitalWrite(LEDheartbeat, HIGH);
//  CAN_stufffff();
//  pFod_stuff();
//  TenMillisStuff();
}

On attached screenshot the digitalWrite took 2,27ms while analogWrite took 3,25ms.

Thats okay for me:)

Teensy3.1_1ms.jpg

Dušan
 
Last edited:
The PWM hardware uses double buffering. When you use analogWrite, the current PWM cycle uses the buffered value, even if that value is zero. Your write takes effect on the next PWM cycle.

For testing, try using analogWriteFrequency(led8, 100000) to set a much higher PWM frequency. The double buffering will still apply, but a shorter PWM period will allow you to observe the effect much sooner.
 
Hello Paul,

thanks for info, You are right, the PWM started much faster, the time diff between digitalWrite and analogWrite (on logic analyzer) was arount 7,2us, in reality it could be plus 5us (as far as i remember correctly).

Teensy3.1_2ms_PWMFreq.jpg

Dušan
 
Only from curiosity:
Why is the startup time important for a turnsignal ?
(pls excuse my ignorance)
 
Last edited:
Only from curiosity:
Why is the startup time important for a turnsignal ?
(pls excuse my ignorance)

No problem Frank,

if i used arduino with bootloader, the LEDs would not turn on, since the bootloader takes around one second.
Thats more than time the original bulb is powered.

I have measures that while flashing, the bulb is powered for around 600ms, i have 9 LEDs.
So thats 66 ms for one LED.
If i wanted to just divide 600ms by 9, the last LED would light too short, so i planned to make the whole sequence finish roughly at 500ms so there will be another 100ms when all the LEDs will be on at full duty cycle.

I know, it is not so time critical, but i want the LEDs to be on at the end of the sequence as much as possible:))

I am attaching photo of (originally) drl, where i will replace white 5050 LEDs with amber 1W LEDs.

IMG_5941.JPG
 
Status
Not open for further replies.
Back
Top