Low Power "Green" Battery Operation Solutions For The Teensy 3.

Status
Not open for further replies.
This library really is quite wonderful for simple low power mode switching--nice work!

One question: on my project I'd like to use low power run, but only when the device is being powered by an external battery (with 3v3 applied directly to the T3's 3v3 pin and not Vin) and not when powered on and connected to USB as a keyboard. Are there any API methods for detecting whether the device is connected via an active USB connection in setup{} before setting the appropriate power mode for that session? Or whether the T3 is being powered by external battery power vs VUSB (from either a computer or a USB power adapter)?

Thanks!
 
One question: on my project I'd like to use low power run, but only when the device is being powered by an external battery (with 3v3 applied directly to the T3's 3v3 pin and not Vin) and not when powered on and connected to USB as a keyboard. Are there any API methods for detecting whether the device is connected via an active USB connection in setup{} before setting the appropriate power mode for that session? Or whether the T3 is being powered by external battery power vs VUSB (from either a computer or a USB power adapter)?

Since nobody else has replied I'll take a shot at mentioning some things. First, you can't hook a battery to the 3.3V pin. It's an output from the internal regulator. We too have a battery operated application that can be hooked up or not to USB. The way we have hooked it up (and the way I think it sort of has to be hooked up) is to cut the jumper on the T3 board between the Vusb and Vin pins. We then ran Vusb to a charger chip hooked to our battery. The battery output feeds into Vin. The 3.3V output drives a few 3.3 chips we have in our design.

To detect when the USB is connected we ran the Vusb also to a 33k ohm/56K ohm resistor divider and then hooked up the mid point to a digital input pin on the T3. When USB is connected that input will read as a digital high signal. When it isn't it will read low. We picked one of the digital inputs that can be used with the LLWU for this connection so plugging in the USB can wake up the processor, allowing us to change operation in that case.

There is a "USB Device Charger Detection" module built into the processor that is supposed to help detect a USB connection. But the reference manual says you have to know USB is hooked up before using that module. That seems sort of weird since one would think that, by its name, such a module would let you detect the act of the USB being plugged in. I'll investigate that module further once I get other things working but adding the Vusb hookup via a divider network was an easy enough addition.
 
Thanks for this helpful response--I had a feeling that physically connecting VUSB to a pin and reading that was the way to go but wasn't sure if there was a software-only method I was missing.

I'm applying 3.3V in to the Teensy's 3.3V pin since I'm using an external step-up regulator (from 1x AA) that performs the same role as the LDO regulator from Vin to 3.3. So what I'm thinking is that, given this, I can monitor either Vin or VUSB using your method because any voltage that comes in from the 3.3V pin won't make it upstream to the inputs on the Teensy's on-board LDO regulator.

These should all be pretty straightforward things to verify with the multimeter, so I'll work on that sometime this week. Thanks again for the pointers!
 
@froeber
I started mapping out my use of LLS and realized I had to change some of my pinouts to get the right connections to the limited set of wakeup pins that are usable. Then I checked your PIN definitions in Lowpower_Teensy3.h. They all looked good but I noticed you left out a few. There was the LED pin 13 (value 0x200) and then the "back side" pins 26 (0x1), 30 (0x800) and 33 (0x8). I'll be checking out the rest of the LLS code as I go to use it. Good effort!
Did you verify these? I'm interested in using pin 26 but it isn't working for me. I copied one of duff's deepsleep examples and it uses pin 22 and that works just fine. But shifting it to pin26 (0x1) makes it stop working.
And let me add thanks to @duff for the library.
 
LLWU use for low power modes

@Roger
Did you verify these? I'm interested in using pin 26 but it isn't working for me. I copied one of duff's deepsleep examples and it uses pin 22 and that works just fine. But shifting it to pin26 (0x1) makes it stop working.

Roger, You asked about checking out pin 26. I didn't check it out explicitly because we don't use any of those pins you have to solder to the bottom pads for. But I have no reason not to think it would work just like the others. I'm using LLS mode for low power in our app and it works great. I based my stuff of Duff's code but made some changes to get things to operate more the way I wanted. I have to say I was having trouble with getting the right wakeup behavior using the LLWU unit in the processor. Looking through lots of code including the App Note 4503 and 4470 that Duff based his stuff on as well as some other Freescale examples and their MQX RTOS low power code I realized that there wasn't a real clean way to set things up to get interrupts to work reliably with the wakeup code being used. And there were various Freescale forum posts on the issues. So I wrote up some code to do the setup a bit differently to allow easier configuration of different types of wakeup and to get interrupts working.

I'll attach a Zip file with the LLWU code I did. If using the LLS or VLLSx power down modes, you can use this code to configure wakeups. And you can set it up to do interrupts by passing the same interrupt handler to the llwu_configure_pin function as you use with attachInterrupt. I'm busy wrapping up our application code but the LLWU stuff has been working great and seems totally reliable now. Plus, we use 2 module and 6 pin wakeup sources with the pins having to trigger on different edges so having incremental setup works well.

I haven't put together any sort of example code but the code is heavily commented and so I hope can be figured out easily enough if someone wants to use it. An example of one of our pin configurations is:

Code:
    /* We want to be able to wake up on an interrupt from the top button. The
     * top button is "active low" so trigger on falling edge. Make sure we set
     * up LLWU for correct digital pin.
     */
    assert(SL_HW_PIN_TOP_BUTTON == 9);
    attachInterrupt(SL_HW_PIN_TOP_BUTTON,
                    top_button_interrupt_handler, FALLING);
    llwu_configure_pin(LLWU_PIN_9, LLWU_WAKEUP_FALLING,
                       top_button_interrupt_handler);
 

Attachments

  • llwu.zip
    11 KB · Views: 194
Using llwu code for LLS low power operation

In case anyone wanted to use the llwu code I posted earlier I thought I would provide the code we use for entering LLS mode as a sample of using the LLWU code. I should also mention that we only use LLS low power mode and not any of the VLLSx low power modes. So I haven't tested that code I posted with anything other than LLS operation. But since LLS mode seems like a nice low power mode to use in terms of getting pretty good power savings and easy wakeup and recovery, I thought it would still be worth posting in case it could help anyone else.

The code below shows where we enable the LLWU. The code has a "power_users" variable. That's a bit mask where each bit indicates a different reason that the code has to stay out of low power mode (for instance doing USB transfers or having an LCD backlight on that needs higher power than the regulator supplies in sleep mode). It was important to mask interrupts when going to sleep to avoid cases where some interrupt came in that indicated a need for high power operation right before we went to sleep and stayed asleep till something else woke us up.

Code:
/**
 * This function enters LLS mode from run mode.
 *
 * This function causes the processor to go into a "low leakage stopped" state
 * until some wakeup source monitored by the processor's LLWU module triggers
 * and wakes up the processor. Upon wakeup, the processor returns to the normal
 * "run" mode of operation.
 *
 * This code is loosely based on the Freescale App Note 4470 code that
 * supports "low power" operation.
 */
static void
enter_lls_mode(void)
{
    volatile uint8_t dummy_read __attribute__ ((unused));

    ELOG(7, 1, "power enter_lls", ELOG_ALWAYS);

    /* Always expect to be in PEE power mode when we start this function */
    assert(mcg_mode_check() == MCG_MODE_PEE);

    /* Make sure clock monitor is off so we don't get spurious reset */
    MCG_C6 &= ~MCG_C6_CME0;

    /* We want to finish all serial output and shut it down before stopping
     * the processor since the UART is disabled in LLS mode.
     */
#ifdef SL_OPT_DEBUG
    SL_DEBUG_PRINT("Z");
    Serial1.end();
#endif

    /* Disable JTAG TDO pin since it can cause problems entering LLS mode.
     * This code is from the code for App Note 4470.
     */
    PORTA_PCR2 = PORT_PCR_PE | PORT_PCR_PS;

    /* Turn off the SYSTICK timer while we are stopped so that elapsed time
     * interrupts don't happen. We had problems that these interrupts caused
     * aborts from stop mode.
     */
    SYST_CSR &= ~SYST_CSR_ENABLE;

    /* Set the power mode control register (PMCTRL) STOPM field to select the
     * LLS mode.
     */
    SMC_PMCTRL = SMC_PMCTRL_STOPM(0x3);

    /* Wait for write to complete to SMC before stopping core */
    dummy_read = SMC_PMCTRL;

    /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP). We don't want
     * other bits in register (eg SLEEPONEXIT) set.
     */
    SCB_SCR = SCB_SCR_SLEEPDEEP;

    /* We don't want to go to sleep if, since our last check, we have gotten
     * an interrupt indicating that we shouldn't sleep. We do this check in a
     * critical section coupled with going to sleep so we don't miss any
     * interrupts.
     */
    __disable_irq();
    if (power_users == 0) {
        llwu_enable();
        /* WFI instruction will start entry into LLS mode */
        ELOG(7, 2, "power WFI", ELOG_ALWAYS);
        asm("WFI");
        ELOG(7, 3, "power WFI done", ELOG_ALWAYS);
    } else {
        ELOG(7, 4, "power WFI skipped", ELOG_ALWAYS);
    }
    __enable_irq();

    /* Start back up the serial port if needed. Note, output may not actually
     * work right if we have to restore the clock settings until we get that
     * done.
     */
#ifdef SL_OPT_DEBUG
    Serial1.begin(SL_DEBUG_BAUD);
    ELOG(7, 7, "power serial started back up", ELOG_ALWAYS);
#endif

    /* When an interrupt occurs we wake up from LLS and come back to this
     * point in Run mode. If we did got into LLS mode, we came back out of that
     * mode via an interrupt to the LLWU that was handled by the wakeup_isr
     * code in llwu.c. That code put us back to PEE power mode if we had gone
     * into PBE mode while stopped. If we didn't successfully go into LLS mode
     * then we should still be in PEE power mode but will have an "abort"
     * signaled by the STOPA bit in the PMCTRL register.
     */
    assert(mcg_mode_check() == MCG_MODE_PEE);

    /* Turn back on external clock monitor */
    MCG_C6 |= MCG_C6_CME0;

    /* Reset the SysTick counter and enable it to start a new countdown cycle.
     * We stopped it before going into LLS mode.
     */
// TODO we lose all sense of elapsed time doing this. Could do different
    SYST_CVR = 0;
    SYST_CSR |= SYST_CSR_ENABLE;

    /* We should have gone into LLS mode and woken up on an interrupt.
     * However, there could have been some issue starting LLS in which case
     * an "abort" will be signaled by the STOPA bit in the PMCTRL register.
     * For now we just display a different letter on the debug output to
     * indicate the problem.
     */
    SL_DEBUG_PRINTLN((SMC_PMCTRL & SMC_PMCTRL_STOPA) ? "A" : "N");
}

I figure I should mention that when I was first trying to get low power operation working using the nice code Duff supplied as a jumping off point I was running into issues where I wasn't properly going into low power operation but instead getting the WFI abort signal. This was with the large set of wakeup sources we are using and the many different processor HW modules we have active. That was what was making proper operation harder to get working. The code we use now doesn't have that problem with aborts. We have the debug printout on the last line above that shows whether the wakeup was a normal one or any immediate one due to aborts. We get reliable normal wakeups. I mention this because I found that all the Freescale code examples ignored whether the low power transition worked or was aborted. When the transition aborts you don't get the power savings you would expect but otherwise don't really notice any issues.
 
Heh. I need something a bit simpler, but thanks for coming back so fast. :)
My particular case only needs one pin for the wakeup, I don't need RTC or Touch or any of the other options. I figured I'd use one of the underneath pads 'cos I have something connected to all the others.
However, I found I was okay using pin 11. I only have one of the SD lines connected to that and it seems to share just fine. When I ground pin 11 I get the wakeup.
The requirement here is that my hand held (actually wrist mounted) device will go to sleep when there's no activity and wake up on a button press. So that's looking good using LLS
Worst case if I find the SD card doesn't work now (still checking that) I can move its connection to underneath.
Thanks again.
 
Heh. I need something a bit simpler, but thanks for coming back so fast. :)
My particular case only needs one pin for the wakeup, I don't need RTC or Touch or any of the other options. I figured I'd use one of the underneath pads 'cos I have something connected to all the others.
However, I found I was okay using pin 11. I only have one of the SD lines connected to that and it seems to share just fine. When I ground pin 11 I get the wakeup.
The requirement here is that my hand held (actually wrist mounted) device will go to sleep when there's no activity and wake up on a button press. So that's looking good using LLS
Worst case if I find the SD card doesn't work now (still checking that) I can move its connection to underneath.
Thanks again.

I'm planning on adding the rest of the digital pin wake ups when i get some time.
 
I am having some problems using LLS mode and USB.
I want to operate from an external power source (battery), sample data at a rather slow rate (4-10Hz), and then save data to SD. In the time between samples, i want to put the mcu in LLS mode. As soon the usb cable is plugged in, the board is powerded by USB, woken up if sleeping and the data from SD is transfered to the connected PC. So far, sampling data, writing to SD, going to LLS mode, wakeup by LPTMR, and usb connection seem to work reliable. My problem right now is the USB data transfer. Once the T3 has gone to LLS mode and woken up again, my PC doesn't recognize the T3 ( it sees a device has been attached, but can't recognize it). I tried calling usb_init() after wakeup, but it doesn't help. I am bit lost here. I'd be gratefull for any hints.
 
I am having some problems using LLS mode and USB.
I want to operate from an external power source (battery), sample data at a rather slow rate (4-10Hz), and then save data to SD. In the time between samples, i want to put the mcu in LLS mode. As soon the usb cable is plugged in, the board is powerded by USB, woken up if sleeping and the data from SD is transfered to the connected PC.

So are you powering the teensy with a power supply and usb at the same time? If so, did you put in the diodes so current does not back flow to your computer? Not sure of your setup here.

Once the T3 has gone to LLS mode and woken up again, my PC doesn't recognize the T3 ( it sees a device has been attached, but can't recognize it). I tried calling usb_init() after wakeup, but it doesn't help. I am bit lost here.

Is this a windows computer, i use mac and have not noticed this problem before. You need to post more details like what device does it say it is when plugged back in preferably screen shots. Since i mostly use mac and linux I really don't know off hand what the problem would be if you use windows.
 
I have diodes to separate external power source and usb power. When running from usb power, i don't switch into LLS mode, to be able to comunicate over usb. When usb is disconnected, i switch into LLS mode, wait for a timer interrupt from lptmr, do some adc reading, and switch back to LLS mode. When first started with a usb connection, the device is recognized by windows, and i am able to comunicate. Once i unplug usb and plug it in again, windows doesn't recognize the device. Error is something similar to "Unable to recognize USB device" (translated from memory, so this might not be accurate). There is no device listed in windows. I am not sure if this is really connected to the LLS mode, because i think, i saw similar behaviour with the blink sketch running (i will check that tomorrow).
 
After having fixed my previously mentioned problems, LLS mode works fine. Now i am facing a new problem. I still see a offset of about 7 ma . I assume, this is the Mini54 as mentioned earlier. I am using software version 116. How can i check if the update was correct or if it is still running an earlier version ? Is this update without user interaction, or might i have missed something ?
 
High power in LLS

After having fixed my previously mentioned problems, LLS mode works fine. Now i am facing a new problem. I still see a offset of about 7 ma . I assume, this is the Mini54 as mentioned earlier. I am using software version 116. How can i check if the update was correct or if it is still running an earlier version ? Is this update without user interaction, or might i have missed something ?

Paul talked about how to check loader version in http://forum.pjrc.com/threads/23880-Teensyduino-1-15-Released. The 7ma certainly sounds like the Min54 is still running. I get .5mA in LLS mode but have other peripherals like an LCD screen running too.

You said you were doing analog sampling after coming out of LLS. So I assume you reinitialize the ADC each time you wake up? I found that code that saves the calibration data and restores it rather than running a whole new calibration cycle runs much faster in case you are worried about speed.
 
I go my power consumption down to 1.2 mA. Source of power consumption wasn't the Mini54 as suspected, but the SD-Card adapter. I was supplying the adpater with 3.3V, and had the power regulator brigded. After taking the power regulator of the board, power consumption dropped by 5mA. I am still a bit of target, but for the prototypes, this will do. Once i have new boards (allready ordered), i'll do further tests.
You said you were doing analog sampling after coming out of LLS. So I assume you reinitialize the ADC each time you wake up? I found that code that saves the calibration data and restores it rather than running a whole new calibration cycle runs much faster in case you are worried about speed.
Speed is of no concern for me, as i only sample 4 times a second, most of the time, the board is sleeping. When exactly is recalibration needed ? During measurement, i have to switch between external and internal reference voltage. From the code i can see, adc gets recalibrated every time i switch reference.
 
If any one wants to check out my latest beta code for the low power library you can view it on github here. I'm updating it currently so things might change but core functionality will remain the same. Some new features:

1. user callback function when waking from DeepSleep and Hibernate.
2. All DeepSleep and Hibernate pins now defined.
3. New Sleep function, users can now use any interrupt to exit from this mode. This function currently has no parameters but will probably change in the future.
4. Added Compare wakeup, this still needs configuration help so if anyone has experience with this help me out.
5. replaced Run function with CPU function, now users can choose from 2, 4, 8, 16 MHz. 2, 4 MHz are in VLPR mode and 8, 16 are not.
6. Added support for using HardwareSerial at 2,4,8,16 cpu MHz.
7. IntervalTimer to work at 2,4,8,16 with a edit to that library. Change private members to protected then un commit that class in LowPower library. If not must recalibrate manually the interval.

Since most of the core is configured for F_CPU, F_BUS, F_MEM i'm slowly trying to port over functions to work at slower clock speeds. Things like SPI, ADC and such are not trivial so these might be some time until they work as expected in slower clock speed so if you have any ideas to help let me know.
 
Hey duff, great to see the lib and thanks for publishing it.
I'm working through your methods and looking at the manual. I'd like to integrate low power into a simple event tasking system I'm creating -
https://github.com/neilh10/arduino/tree/master/teensy3/taskingSimple
https://github.com/neilh10/arduino/tree/master/libraries/sondeLib
http://forum.pjrc.com/threads/25278-Low-Power-with-Event-based-software-architecture-brainstorm

One thing I'm running into a problem with is how to pull your tree into an Arduino library.
https://github.com/duff2013/LowPower_Teensy3
Is it possible to describe how the above github should be pulled into an Arduino 1.x that has been updated for building Teensy31
The way I'm trying it isn't working.

I'm actually building in an Eclipse/CDT environment based on the Arduino 1.x/Teensy31 release 1.18. Eclipse is way more productive than the fast-to-install but simple Arduino. I've organized so that I can push it into the Arduino format easyly to be able to share it.

One of the issues in the MK20 architecture is that all the subsystems are tied into the SYS_CLK and it appears the first recommended way of dealing with low power is to change the clock to 2MHz, and then disable SYS_CLK, which impacts peripherals timings.
I had the same issues with the ATmega2560 when I implemented low power, and I solved that with a system wide advertisement of going into low power mode.
So I'm enjoying looking at what you've done and experimenting with integrating it into a larger model.
Have you any thoughts on being able to manage all the peripheral dependencies on the SYS_CLK?
thanks
Neil
 
One thing I'm running into a problem with is how to pull your tree into an Arduino library.
https://github.com/duff2013/LowPower_Teensy3
Is it possible to describe how the above github should be pulled into an Arduino 1.x that has been updated for building Teensy31
The way I'm trying it isn't working.
I just download the zip file and deleted the master part in the name, then install it in the libraries folder in arduino. As far as eclipse I don't know but maybe someone who reads this can help you with that.

One of the issues in the MK20 architecture is that all the subsystems are tied into the SYS_CLK and it appears the first recommended way of dealing with low power is to change the clock to 2MHz, and then disable SYS_CLK, which impacts peripherals timings.
What do you mean by the SYS_CLK? -->F_CPU clock.

I don't disable any clocks just reconfigure them for the reduced freq. You can disable peripheral's that you don't use though. This will help with overall current consumption.

Have you any thoughts on being able to manage all the peripheral dependencies on the SYS_CLK?
If you mean F_CPU, the real sticking point here is the teensy core is tied to F_CPU, F_BUS, F_MEM so peripheral's will not work right if you dynamically change the core's clock speeds. For an example look at how I reimplemented the Hardware Serial classes in the library for whatever cpu and bus speeds you are currently running. That is how I'm trying to solve this issue without editing the core.

Hope this helps,
duff
 
Thanks for the response. On the install I can't see what you mean by delete the Master.
So I've probably not got something set up right or doing a procedure wrong so I'll run through it, and any insights appreciated.

I have a Arduino 1.05-r2 updated Teensyduino 1.18.
That is downloaded and installed http://www.pjrc.com/teensy/td_download.html - teensyduino.exe that I renamed as teensyduinoV118.exe
On the Tools I have set - Tools -->Board-->Teensy3.1
And it works and I can download programs to the Teensy31 board and flash the LED etc.

I download your http://duff2013.github.io/LowPower_Teensy3/ as .zip
I unzip it into a directory (deleteing duff2013- as the library manager doesn't like the '-')
Arduino\libraries\LowPower_Teensy3
I start the Arduino IDE


and I open
File->Sketchbook->Libraries->LowPower_Teensy3-->LowPower_Simple-->Sleep_Simple
Then I press verify button and get the following errors: (and also for all T3LP examples)

Arduino: 1.0.5-r2 (Windows NT (unknown)), Board: "Teensy 3.1"
C:\Program Files\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=118 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files\Arduino\hardware\teensy\cores\teensy3 -IC:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3 C:\Users\neilh77\AppData\Local\Temp\build7612172344359111544.tmp\Sleep_Simple.cpp -o C:\Users\neilh77\AppData\Local\Temp\build7612172344359111544.tmp\Sleep_Simple.cpp.o

In file included from Sleep_Simple.ino:13:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h: In static member function 'static uint32_t TEENSY3_LP::micros()':
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:155:49: warning: no return statement in function returning non-void [-Wreturn-type]
In file included from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/WProgram.h:35:0,
from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
from C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:32,
from Sleep_Simple.ino:13:
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h: At global scope:
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h:33:25: error: 'typedef void (* IntervalTimer::ISR)()' is private
In file included from Sleep_Simple.ino:13:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:165:16: error: within this context
In file included from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/WProgram.h:35:0,
from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
from C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:32,
from Sleep_Simple.ino:13:
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h: In member function 'bool IntervalTimer_LP::begin(IntervalTimer::ISR, unsigned int)':
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h:37:71: error: 'const uint32_t IntervalTimer::MAX_PERIOD' is private
In file included from Sleep_Simple.ino:13:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:166:43: error: within this context
In file included from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/WProgram.h:35:0,
from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
from C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:32,
from Sleep_Simple.ino:13:
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h:37:71: error: 'const uint32_t IntervalTimer::MAX_PERIOD' is private
In file included from Sleep_Simple.ino:13:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:166:43: error: within this context
In file included from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/WProgram.h:35:0,
from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
from C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:32,
from Sleep_Simple.ino:13:
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h:51:10: error: 'bool IntervalTimer::beginCycles(IntervalTimer::ISR, uint32_t)' is private
In file included from Sleep_Simple.ino:13:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:168:16: error: within this context
In file included from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/WProgram.h:35:0,
from C:\Program Files\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
from C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:32,
from Sleep_Simple.ino:13:
C:\Program Files\Arduino\hardware\teensy\cores\teensy3/IntervalTimer.h:51:10: error: 'bool IntervalTimer::beginCycles(IntervalTimer::ISR, uint32_t)' is private
In file included from Sleep_Simple.ino:13:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:168:44: error: within this context
 
Sorry i guess the version on github doesn't have the IntervalTimer_LP class commented out in the LowPower_Teensy3.h. Just delete or comment it out like so:

Code:
/*
class IntervalTimer_LP [B]:[/B] public IntervalTimer {
private:
public:
    [COLOR=#445588][B]bool[/B][/COLOR] begin(ISR newISR, [COLOR=#445588][B]unsigned[/B][/COLOR] [COLOR=#445588][B]int[/B][/COLOR] newPeriod) {
        [B]if[/B] (newPeriod [B]==[/B] [COLOR=#009999]0[/COLOR] [B]||[/B] newPeriod [B]>[/B] MAX_PERIOD) [B]return[/B] [COLOR=#0086B3]false[/COLOR];
        [COLOR=#445588][B]uint32_t[/B][/COLOR] newValue [B]=[/B] (TEENSY3_LP[B]::[/B]_cpu [B]/[/B] [COLOR=#009999]1000000[/COLOR]) [B]*[/B] newPeriod [B]-[/B] [COLOR=#009999]1[/COLOR];
        [B]return[/B] [COLOR=#990000][B]beginCycles[/B][/COLOR](newISR, newValue);
    }
};
*/

I'll fix this tonight!
 
Great - thats got it working.
I can get the DeepSleep_simple compiling/downloaded/working
Also compiles Sleep_Advanced,
and working through those examples.

However Hibernate_Simple throws
Arduino: 1.0.5-r2 (Windows NT (unknown)), Board: "Teensy 3.1"
C:\Program Files\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=118 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files\Arduino\hardware\teensy\cores\teensy3 -IC:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3 C:\Users\neilh77\AppData\Local\Temp\build5304130245006401437.tmp\Hibernate_Simple.cpp -o C:\Users\neilh77\AppData\Local\Temp\build5304130245006401437.tmp\Hibernate_Simple.cpp.o

In file included from Hibernate_Simple.ino:15:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h: In static member function 'static uint32_t TEENSY3_LP::micros()':
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:155:49: warning: no return statement in function returning non-void [-Wreturn-type]
Hibernate_Simple.ino: In function 'void setup()':
Hibernate_Simple:33: error: no matching function for call to 'TEENSY3_LP::printSRS()'
Hibernate_Simple.ino:33:15: note: candidate is:
In file included from Hibernate_Simple.ino:15:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:152:10: note: void TEENSY3_LP::printSRS(Stream*)
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:152:10: note: candidate expects 1 argument, 0 provided

Hibernate_Advanced
Arduino: 1.0.5-r2 (Windows NT (unknown)), Board: "Teensy 3.1"
C:\Program Files\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=118 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files\Arduino\hardware\teensy\cores\teensy3 -IC:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3 -IC:\Program Files\Arduino\libraries\Time -IC:\Program Files\Arduino\libraries\EEPROM C:\Users\neilh77\AppData\Local\Temp\build5304130245006401437.tmp\Hibernate_Advanced.cpp -o C:\Users\neilh77\AppData\Local\Temp\build5304130245006401437.tmp\Hibernate_Advanced.cpp.o

In file included from Hibernate_Advanced.ino:15:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h: In static member function 'static uint32_t TEENSY3_LP::micros()':
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:155:49: warning: no return statement in function returning non-void [-Wreturn-type]
Hibernate_Advanced.ino: In function 'void sleep_config_1()':
Hibernate_Advanced:86: error: 'struct configSleep' has no member named 'callbackfunc'
Hibernate_Advanced.ino: In function 'void sleep_config_2()':
Hibernate_Advanced:110: error: 'struct configSleep' has no member named 'callbackfunc'
Hibernate_Advanced.ino: In function 'void sleep_config_3()':
Hibernate_Advanced:135: error: 'struct configSleep' has no member named 'callbackfunc'

DeepSleep_Advanced
Arduino: 1.0.5-r2 (Windows NT (unknown)), Board: "Teensy 3.1"
C:\Program Files\Arduino\hardware\tools\arm-none-eabi\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=118 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_SERIAL -DLAYOUT_US_ENGLISH -IC:\Program Files\Arduino\hardware\teensy\cores\teensy3 -IC:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3 -IC:\Program Files\Arduino\libraries\Time C:\Users\neilh77\AppData\Local\Temp\build5304130245006401437.tmp\DeepSleep_Advanced.cpp -o C:\Users\neilh77\AppData\Local\Temp\build5304130245006401437.tmp\DeepSleep_Advanced.cpp.o

In file included from DeepSleep_Advanced.ino:12:0:
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h: In static member function 'static uint32_t TEENSY3_LP::micros()':
C:\Users\neilh77\Documents\Arduino\libraries\LowPower_Teensy3/LowPower_Teensy3.h:155:49: warning: no return statement in function returning non-void [-Wreturn-type]
DeepSleep_Advanced.ino: In function 'void sleep_config_1()':
DeepSleep_Advanced:59: error: 'struct configSleep' has no member named 'callbackfunc'
DeepSleep_Advanced.ino: In function 'void sleep_config_2()':
DeepSleep_Advanced:97: error: 'struct configSleep' has no member named 'callbackfunc'
 
Ya those examples are from an old version, I'll update them on github so they work but prolly will not happen until tomorrow. DeepSleep and Hibernate function exactly the same except Hibernate comes out of sleep mode through a reset where DeepSleep continues program flow after the call to DeepSleep.

or you could just download the last stable release here.
 
Last edited:
Ya those examples are from an old version, I'll update them on github so they work but prolly will not happen until tomorrow. DeepSleep and Hibernate function exactly the same except Hibernate comes out of sleep mode through a reset where DeepSleep continues program flow after the call to DeepSleep.

or you could just download the last stable release here.

Might be a good idea to tag your releases on github, so people can easily grab the stable or HEAD version as they prefer. Happy to help organize if I can, or work on additional features if a roadmap is documented so I know where to direct my efforts.

Thanks much for all your work on this I've been using the stable version in a couple of prototypes for the last few weeks and it's been exceptionally helpful.
 
Status
Not open for further replies.
Back
Top