nishanth 0 Posted April 26, 2017 Share Posted April 26, 2017 Can anyone provide energia code for hibernate mode or sleep mode in tiva launchpad EK-TM4C123GXL Quote Link to post Share on other sites
Rei Vilo 695 Posted April 26, 2017 Share Posted April 26, 2017 No need to post twice! No need to use capital letters! See Netiquette for Newbies. Quote Link to post Share on other sites
wg0z 0 Posted April 27, 2017 Share Posted April 27, 2017 (edited) 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 April 28, 2017 by wg0z better answer to OP Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.