Jump to content

getting the hibernate library to play nice

Recommended Posts

Trying to get the hibernate library to work as in the pastebin example for the tm4c123 here. I've modified it with the request at the end.

//#include <DateTimeLibrary.h>

#include "driverlib/hibernate.c"
boolean redstate = false;
boolean bluestate = false;
int green = 0;
void setup()
  uint32_t hibact = HibernateIsActive();
  // put your setup code here, to run once:
  pinMode(BLUE_LED, OUTPUT);
void HibernateHandler(void)
  //Use this to reset interrupt flag
  uint32_t ui32Status = HibernateIntStatus(1);
  //Place here code to execute every second, ex: LCD or 7 segment display
  //Altough it should be as fastest as possible
  redstate = !redstate;
  //To keep the interrupt hapening every second you need this
void loop()
  // put your main code here, to run repeatedly:
  bluestate = !bluestate;
  if(redstate ==0){
   green = 0;
  else green = 64;
  analogWrite(GREEN_LED, green);
  if (bluestate) {
    analogWrite(BLUE_LED, 64);
  else {
    analogWrite(BLUE_LED, 0);

Been reading through 16.2 API Functions for the hibernate module here and can figure out whats going on. I just want the hibernate module to be requested once main has run, this doesn't seem to happen and the hibernate interrupt just seems to function as a timer running alongside the main function...???
Tried adding HibernateWakeSet(HIBERNATE_WAKE_RTC); to the setup

Link to post
Share on other sites

That code as just to use the hibernation module RTC and Calendar mode, it's not even a library! There is 0 power saving features implemented. I actually never used it for that. 

" the hibernate interrupt just seems to function as a timer running alongside the main function.." that's exactly what's it's doing.

Btw the calendar mode only works with the tm4c129x if I remember correctly.

 I just want the hibernate module to be requested once main has run" well, it is requested, it's already on :P
Please explain a bit more.

Link to post
Share on other sites

Ok so I want to save battery life, I thought I could get the chip to power down when hibernating (which I assumed meant main would not run?).

I also thought not as relevantly I could save power by powering via vbus and removing the jumper pin to (I hoped) disconnect the debug chip...
I dont need calendar mode since I'm using a timedate library.


Am I totally misunderstanding the hibernate module??!

Link to post
Share on other sites

Nope, you just totally misunderstand the purpose of that code example. That just shows how to use some of the features, that actually can be use in normal run mode.
In any sleep mode there's not any code that will run. You need a wake up source to get back to the code, in hibernate mode (compared to other sleep modes) there's actually very few wake up sources.
There's actually a sleep() function in Energia but I never tested it out. I think you can set the device to sleep of x milliseconds. 

The debug chip actually consumes a lot (something like 50mA in the TM4C123 if I am not mistaken) and as far as I know, you can't actually disconnect it in the tm4c123 launchpad as weird as it seems.

Link to post
Share on other sites

I don't understand how TI brought this out to go against Arduino when example codes for the hardware are so scarce, clearly they don't focus on the hobbyist market, or at least they really suck at doing it. Energia is linked on the launchpad website.. should it be confusing something as simple as power management would appear so tricky. I guess I'm just going to keep poking it with a stick until it works?

Link to post
Share on other sites

This type of code as nothing to do with Energia/Arduino!
This is low level coding with low level libraries (just above register programming)! Like in arduino you can use register programming, or if using a Arduino Due, use low level libraries too, to have full access to your hardware. Of course with time there's high level libraries that appear but this type of feature is MCU specific = less likely for a library to appear.

Power management = simple? It can actually be quite complex! Which sleep mode? Which peripherals should be on? With which clock on and in which bus? What are the wake up sources? Chose the right core voltage and clock source and speed for different wake up times and consumption.

Granted that there's fewer code examples for some features but don't compare the size of the community + lots of users here go to low level programming for the advantages it brings (or a mix).

You should be able to use these for delays where the cpu sleeps:

void sleep(uint32_t milliseconds);
void sleepSeconds(uint32_t seconds);

There's also a void suspend(void); that I think works by using a interrupt as a wake up source.

And if you really want to go for low level programming with Tivaware libraries, there's actually plenty of examples on the package including some for the hibernate module
Link to post
Share on other sites

What @L.R.A said, and to elaborate further...


There are several places where sleep(), sleepSeconds(), suspend(), and wakeup() are discussed in 43oh forums.  Energia on the TI microcontrollers actually has fairly sophisticated energy management features.  For example, see this recent post on the 43oh blog and this simple example.  I tried the example just now on the EK-TM4C123GXL with Energia 16 on my Windows 10 machine and it works fine.

Link to post
Share on other sites



I have used it successfully on MSP430 microcontrollers as documented in the blog post linked above. I am not as familiar with the other TI microcontrollers and after looking back I am not sure how the functions are implemented in Energia on the EK-TM4C123GXL. If you want full control of power modes it is better to use the libraries that TI provides and CCS as L.R.A suggests.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...