Jump to content
43oh

wg0z

Members
  • Content Count

    4
  • Joined

  • Last visited

Posts posted by wg0z

  1. 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()

×
×
  • Create New...