Teensy 4.0 Low Power

duff

Well-known member
Hi All, just wanted to gauge the priority of low power operation of the Teeny 4.0? I have worked on it for Snooze off and on for a bit now and it's not exactly an easy thing to implement since it is much different than Kinetis M micro's (T3x/LC). So post here if you need this and if enough people want it I will work on it now. Also if anyone wants to help please do:D and follow-up on this thread.
 
Dear duff, thank you for your Snooze library. T4 is currently useless to me compared to T3.5/6 because of the vastly inferior 24mhz power consumption vs the T3.5/6 at 24mhz. It isn't even the same: it is actually worse than T3.5/6, when the processor datasheets' indications of mhz v. ma would have you believe it should be better (actually, vastly better).

I am holding off on further T4 purchases until I can get a power optimization, not a power worsening, from it compared to T3.5/6. See this thread for further info:
https://forum.pjrc.com/threads/5745...0-24mhz-high-power-consumption-compared-to-3x
 
Hi All, just wanted to gauge the priority of low power operation of the Teeny 4.0? I have worked on it for Snooze off and on for a bit now and it's not exactly an easy thing to implement since it is much different than Kinetis M micro's (T3x/LC). So post here if you need this and if enough people want it I will work on it now. Also if anyone wants to help please do:D and follow-up on this thread.

your Snooze library is fantastic!

it will certainly be welcome when it happens for Teensy4. i have been compiling and running on Teensy4 for 3 weeks now and have become at least a little
familiar with it. have been using Teensylc and Teensy3.6 and Arduino and Teensyduino for not quite 3 years. i am not a real programmer but have been doing
assembly and c for embedded for several decades as a circuit designer and hack programmer and i have a complete test equipment bench. i have a small
collection of Teensylc and Teensy3.6 programs that use the Snooze library to go slow or hibernate that i could compile, run, and test (or send to you).

please let me know if i can be of help.
 
Ok I'll work on this again, it's going to be a slow slog though, there are so many things with the M7 processor that you have consider that you didn't in the arm M0/M4!
 
Hi Duff,

I am wondering how is your with Snooze library going for Teensy 4.0. I am thinking about upgrading my project, but I need a current draw of less than 200uA in hibernate mode (standalone). Is it possible?

Thank you,

Peter
 
Hi Duff,

I am wondering how is your with Snooze library going for Teensy 4.0. I am thinking about upgrading my project, but I need a current draw of less than 200uA in hibernate mode (standalone). Is it possible?

Thank you,

Peter
Currently I only have System Idle(sleep) mode working, next will be LowPower Idle (deepSleep) then Suspend (hibernate). Actually Low Power Idle is coded just haven't tested it yet.
Current wakeup modules are digital, timer and working on compare then rtc.

Have not measured any current draw yet either so can not really tell what the numbers will be.
 
I ran across the need for speed vs power issue on a logger in about 2005. I needed an ARM chip to do a bunch of cubic spline fits about once per minute. That would take a second or so. The rest of the time I wanted to collect that data with minimum power consumption. The solution I came up with was to use an Atmel ARM chip to do the number crunching and an MSP430 to do the data collection. The Atmel chip had the advantage of totally static internal operations, so you could stop the external clock input and the chip would go into low-power sleep. Start the clock again and the ARM chip took up where it left off. The MSP430 controlled the Atmel external clock generator and provided all the timing signals. It sent data and received results with serial ports at 115KB.

The T4 has the capability to do much the same thing---but all the hardware is on the same chip. The shutdown process is complicated by the phase-locked loops that generate a lot of the peripheral clocks---and there are a lot more peripherals than on that 2005 ARM chip.

That historic digression leads to my real point: There are at least two types of 'low power operation:
There is the type that the snooze library tackles: You want the T4 to go into low-power sleep, then wake up intermittently and do some useful work. (The case I tackled with my 2005 multi-processor system).
There is the type that Paul M. wants where the Teensy is awake and running at a reduced clock rate with the minimum possible power consumption. This requires some code to shut down the clocks to unused peripherals to eliminate their power drain.

The best I've done on that is to figure out how to put the SD Card into idle mode between writes at a saving of about 30mA. For most logging operations, I don't need USB, most UARTS, audio, ethernet, the pixel pipeline, PWM, etc. etc. I think, but I'm not sure, that the T4 startup code starts up the clocks to most peripherals, whether they will be used or not. This would seem to be in line with the Arduino philosophy of doing most startup code before getting to the setup() function and having most peripherals ready to go with minimal startup code. This also eliminates the time lag an unlocked peripheral would experience on starting the clock and waiting for a PLL to stabilize.

I think there is still a lot of work to be done to get the T4.0 to match the low-power continuous operation capability of the T3.6. i've been able to get the T3.6 to log 3 analog channels and a time stamp to SD card at 400 samples per second using less than 10mA average current. To do this, I have to run the T3.6 at 8MHz and make sure to put the SD card into idle mode after each write.
 
The T4 has lots of clocks that you have to deal with when trying to lower the RUN mode power draw. For low power modes Low Power Idle (sleep) has the Arm CPU lowered down to 132MHz (arm pll) before shutting down all the PLL's and gating all the peripheral clocks for the myriad of functional blocks like serial, i2c etc except the ones needed for wakeup. The T4 inherits some of the peripherals from the IMX6 and some from the kinetis chips so it's challenge to do all the steps needed to keep the power down. One thing is clear is the change to the application processor design makes the low power sequence much more complicated from the rather easy low power design of the kinetis. There are so many clocks that you can use for each wakeup source it's been a hard to find the right one to use and in the upcoming Snooze T4 beta will probably use not the most power efficient clocks but it's what I had to do to make forward progress. Right now struggling to implement the xbar for the comparator (acmp) to bring out a few channels to top side pins. Might put that on the next beta since it's not a widely used wakeup form anyways.
 
Bumping this for Teensy 4.1. I've just got mine and have started exploring how to reduce the power draw while doing something periodically. Here are some numbers (collected via an Odroid Smart Power at 5V, powering via the Teensy's USB port, with sketches compiled with 24 MHz unless otherwise stated):

- A simple sketch (see below) which uses asm volatile("wfi") in between wakeups via the IntervalTimer to blink an LED draws 213 mW while the LED is off and 225 mW while it is on.
- The same sketch with asm volatile("wfi") uses 244 mW with the LED off and 255 mW with it on.
- At 600 MHz, the LED-off power consumption with and without "wfi" are 286 and 480 mW, respectively.
- At 24 MHz, the Snooze SkeletonDriver example draws about 240 mW while the LED is off and 244 while it is on (although it's perhaps not on long enough to measure this accurately). This is the first time I've used the Snooze library, maybe I'm holding it wrong.
- For comparison, a similar sketch on a Feather M4 at 120 MHz draws about 68 mW in __WFI(), and 38 mW or less with USB disabled in setup() via a register. The Smart Power craps out below 38 mW so I can't measure lower power draws.

Code:
IntervalTimer mytimer;

static volatile unsigned int wake = 0;
static void increment_wake(void) { wake++; }

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  mytimer.begin(increment_wake, 1000000);
}

void loop() {
  if (!wake) {
    asm volatile("wfi");
    return;
  }  
  wake--;

  static char state = 0;
  digitalWrite(LED_BUILTIN, state);
  state = !state;
}
 
Last edited:
Bumping this for Teensy 4.1. I've just got mine and have started exploring how to reduce the power draw while doing something periodically.

If anybody has numbers already for
a) using Ethernet (with the OSH adapter) (target rate 1kHz UDP packets)
b) using USB HID RAW over PJRC Host adapter cable (also 1kHz rate)

I'd much appreciate it. I saw chip's rated at <70mA and board was measured <105mA but I'm at a loss with respect to impact of USB and Ethernet

https://github.com/manitou48/DUEZoo/blob/master/power.txt
https://forum.pjrc.com/threads/24341-Teensy-3-vs-Teensy-2-power-consumption
 
T4 deep sleep problem ? limitation ? under td 1.52

just installed td 1.52 over 1.48. had to delete the "utilities" folder in snooze lib when compiler said cannot use src and utility folder both - utility folder was i guess
a leftover from 1.48 which did not get removed at install 1.52

took from the examples folder deepSleep_all_wakeups.ino and removed all lines did not need for a simple test using deep sleep via rtc
that subset of code is shown below.

for some reason need to include usb in this line SnoozeBlock config_teensy40(usb, alarm) or it does not function even when plugged
into PC usb port. stand alone (just power applied to +5 and gnd pins) it does not function even with usb included that line. Will not
have a PC later in actual application.

Am I misunderstanding something ? Is there a way for the T4 deepsleep to work stand alone ? I see the comment line about T4 and
usb but do not understand it. Any help appreciated.


Code:
// subset of deepSleep_all_wakeups.ino example in td1.52 snooze lib

#include <DogLcd.h>

/***************************************
  This shows all the wakeups for deepSleep

  Supported Micros: T-LC/3.x/4.0
****************************************/
#include <Snooze.h>
// Load drivers
SnoozeTimer timer;
SnoozeUSBSerial usb;
SnoozeAlarm  alarm;

/***********************************************************
  Teensy 4.0 does not have a Touch Interface. Always use the
  SnoozeUSBSerial Driver.

  Teensy 3.6/LC can't use Timer Driver with either Touch or
  Compare Drivers and Touch can't be used with Compare.

  Teensy 3.5 does not Touch Interface.

  Teensy LC does not have a rtc so Alarm Driver can't be
  used as of yet.

  Teensy 3.2 can use any Core Drivers together.
***********************************************************/
SnoozeBlock config_teensy40(usb, alarm);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

//    Set RTC alarm wake up in (hours, minutes, seconds).

  alarm.setRtcTimer(0, 0, 20);// hour, min, sec

}

void loop() {
  int who;
  /********************************************************
    feed the sleep function its wakeup parameters. Then go
    to deepSleep.
  ********************************************************/

  who = Snooze.deepSleep( config_teensy40 );// return module that woke processor

  if (who == 35) { // rtc wakeup value
    for (int i = 0; i < 4; i++) {
      digitalWrite(LED_BUILTIN, HIGH);
      delay(200);
      digitalWrite(LED_BUILTIN, LOW);
      delay(200);
    }
  }

}
 
Currently I only have System Idle(sleep) mode working, next will be LowPower Idle (deepSleep) then Suspend (hibernate). Actually Low Power Idle is coded just haven't tested it yet.
Current wakeup modules are digital, timer and working on compare then rtc.

Have not measured any current draw yet either so can not really tell what the numbers will be.

Start with System Idle ...
 
T4 deep sleep and sleep resolved

thank you defragster - used sleep and found the real problem was mine.

Both (sytem idle) sleep and deepsleep work just fine with just +5 and ground.

I get the dumb*** of the day award - the usb to bench supply adapter with power only and built in banana jacks to lead to bench
DVM I built 2-3 years ago and have used 1000 times had a cold solder joint.

T4 deepsleep = 7.8 ma , sleep = 19.6 ma all done w 5.0 volts, TD1.52, ARD 1.8.5, WIN7pro64, TEENSY 4.0, waking up to rtc,
numbers seem to be independent of clock speed. I will test hibernate as soon as Duff releases it.
 
T4.0 deep sleep / sleep more data

here is more data for T4 sleep all done w 5.0 volts, TD 1.52, ARD 1.8.5, WIN7pro64, TEENSY 4.0,
currents are during snooze, currents seem independent of clock speed

---rtc--deepsleep= 9.8 ma---sleep=19.6 ma
--lptmr-deepsleep=14.4 ma---sleep=24.3 ma
 
Good to see it working! Are those numbers in the expected range?

USB and SerMon with TD 1.52 working well it seems?

Win7 ... what a trooper :)
 
FYI, 'hibernate' sleep should work it just wakes with a reset. I'm not surprised by those numbers, thanks for posting. Currently I'm doing a huge home automation project so I'm not going to look at Low Power stuff anytime soon but I hope to revisit this to work on better power numbers. @dfragster do you know if the bootloader chip goes into low power mode yet? I never saw anything but I haven't been watching this forum closely lately.
 
FYI, 'hibernate' sleep should work it just wakes with a reset. I'm not surprised by those numbers, thanks for posting. Currently I'm doing a huge home automation project so I'm not going to look at Low Power stuff anytime soon but I hope to revisit this to work on better power numbers. @dfragster do you know if the bootloader chip goes into low power mode yet? I never saw anything but I haven't been watching this forum closely lately.

@duff : Don't recall an update on "Bootloader going low power".
 
FYI, 'hibernate' sleep should work it just wakes with a reset. I'm not surprised by those numbers, thanks for posting. Currently I'm doing a huge home automation project so I'm not going to look at Low Power stuff anytime soon but I hope to revisit this to work on better power numbers. @dfragster do you know if the bootloader chip goes into low power mode yet? I never saw anything but I haven't been watching this forum closely lately.

Is that to say that hib only wakes with a reset and not any timers? I can measure the hib current.
Good luck w home automation.
 
Is that to say that hib only wakes with a reset and not any timers? I can measure the hib current.
Good luck w home automation.

Yes, good luck with automation @duff.

@analog&RFmodels - there is a timed sleep method - it is good power down - but wakes going through reset/setup(). Not sure how that relates to snooze - but it was looked at when T_4 restart was failing.
 
T4 snooze data including hibernate

---rtc--deepsleep= 9.8 ma---sleep=19.6 ma
--lptmr-deepsleep=14.4 ma---sleep=24.3 ma

hibernate with all references to timers and timer drivers turned off is 11.8 ma
if i use code that was deepsleep waking from rtc and just replace
who = Snooze.deepSleep with who = Snooze.hibernate drops to 7.4 ma

all done w 5.0 volts, TD 1.52, ARD 1.8.5, WIN7pro64, TEENSY 4.0,
currents are during snooze, currents seem independent of clock speed
 
Here is the thread and a post where hibernate through a timed sleep was abused as a reset shortcut when it wasn't working.

issue-to-reporogram-T4-0

Time has to be given of at least 2 seconds - but larger should work as specified. T_4.x should power down except RTC unit that will wake through startup/setup().
 
Hi duff

Was wondering if the Snooze library supports wake up from CAN bus frame or a wake up signal?
I didn't see any mention of it on the Github readme.

Also, is there any listing current draw for the T4/4.1 in the different sleep modes? I need power consumption to be as low as possible when in sleep mode (uA is the goal).
 
Hi duff

Was wondering if the Snooze library supports wake up from CAN bus frame or a wake up signal?
I didn't see any mention of it on the Github readme.

Also, is there any listing current draw for the T4/4.1 in the different sleep modes? I need power consumption to be as low as possible when in sleep mode (uA is the goal).

please look three posts up for all of those currents. if you can stand a cold start every time, see the link two posts up.
i have used the cold start method w rtc on T4 and average "sleep" current is 220 ua. if you need lower than that and
can stand a cold start you could use TLC and it's 5v output pin to drive a low threshold p channel mosfet of appropriate
ron to power T4 when desired. good news is that during TLC hibernate it will only draw 11-14 ua and the "off" T4 will
only draw maybe 1 ua due to mosfet off leakage. TLC hib time is controlled by lptmr so be prepared to put some tweak
to it to get exact times.
 
Back
Top