SHARE
TWEET

Untitled

a guest Jul 12th, 2014 261 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "driverlib/hibernate.c"
  2. boolean redstate = false;
  3. boolean bluestate = false;
  4. void setup()
  5. {
  6.   // put your setup code here, to run once:
  7.   pinMode(RED_LED, OUTPUT);
  8.   pinMode(BLUE_LED, OUTPUT);
  9.   HibernateEnableExpClk(F_CPU);
  10.   HibernateRTCEnable();
  11.   HibernateRTCMatchSet(0,HibernateRTCGet()+1);
  12.   HibernateIntRegister(HibernateHandler);
  13.   HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
  14. }
  15.  
  16. void HibernateHandler(void)
  17. {
  18.   //Use this to reset interrupt flag
  19.   uint32_t ui32Status = HibernateIntStatus(1);
  20.   HibernateIntClear(ui32Status);
  21.   //Place here code to execute every second, ex: LCD or 7 segment display
  22.   //Altough it should be as fastest as possible
  23.   redstate = !redstate;
  24.  
  25.   //To keep the interrupt hapening every second you need this
  26.   HibernateRTCMatchSet(0,HibernateRTCGet()+1);
  27. }
  28.  
  29. void loop()
  30. {
  31.   // put your main code here, to run repeatedly:
  32.   bluestate = !bluestate;
  33.   digitalWrite(RED_LED, redstate);
  34.   if (bluestate) {
  35.     analogWrite(BLUE_LED, 64);
  36.   }
  37.   else {
  38.     analogWrite(BLUE_LED, 0);
  39.   }
  40.   delay(750);
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top