Jump to content
43oh

Energia code for low power mode in EK-TM4C123GXL


Recommended Posts

here's a bare-bones sketch, developed with Energia 17

 

typedef volatile unsigned long reg_t;
reg_t * pHIBCTL = (reg_t *)0x400fc010UL;  // hibernation control, see datasheet page 505

void setup()
{               
  // set the pin for the red LED as OUTPUT
  pinMode(RED_LED, OUTPUT);    
 
  // enable internal pullup for the pins connected to the pushbuttons
  pinMode(PF_0, INPUT_PULLUP); // SW2 and the /WAKE pin
  pinMode(PF_4, INPUT_PULLUP); // SW1 is connected to this pin
 
} // end setup()

void loop()
{
 
  // flash LED at 4Hz
  digitalWrite(RED_LED, (millis() % 250) < 125);
 
  // if sw1 is pressed, force LED off and enter hibernation
  if( LOW == digitalRead(PF_4))
  {
    digitalWrite(RED_LED, 0);
   
    // code to enter hibernation is per section 7.4.4 of the datasheet   
    // wait for MSB of the regiser to be set
    while (0 == (*pHIBCTL & 0x80000000UL));
    *pHIBCTL = 0x40;
    // wait for MSB of the regiser to be set
    while (0 == (*pHIBCTL & 0x80000000UL));
    *pHIBCTL = 0x52UL;
  }
 
} // end loop()

Edited by wg0z
better answer to OP
Link to post
Share on other sites
  • bluehash changed the title to Energia code for low power mode in EK-TM4C123GXL

Join the conversation

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

Guest
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...