Example #1
0
/* setup with 'weak' link in linker */
void RTC1_IRQHandler(void)
{
    RTC_ClearAlarm(1);
    if (rtc_callback_array[1])
    {
        rtc_callback_array[1]();
    }
}
Example #2
0
/* setup with 'weak' link in linker */
void RTC0_IRQHandler(void)
{
    RTC_ClearAlarm(0);
    if (rtc_callback_array[0])
    {
        rtc_callback_array[0]();
    }
}
Example #3
0
//-----------------------------------------------------------------------------
// RTC_Init ()
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
//
//-----------------------------------------------------------------------------
void RTC_Init (void)
{
   SEGMENT_VARIABLE(Is_RTC_Ready, static U8, SEG_XDATA) = FALSE;

   if (!Is_RTC_Ready) {
      RTC0KEY = 0xA5;                     // unlock the RTC interface
      RTC0KEY = 0xF1;

      RTC_Write (RTC0XCN, 0x60);          // Configure the smaRTClock
      // oscillator for crystal mode
      // Bias Doubling Enabled
      // AGC Disabled

      RTC_Write (RTC0XCF, CAP_AUTO_STEP|LOAD_CAP_VALUE);
      // load capacitance value from rtc.h

      RTC_Write (RTC0CN, 0x80);           // enable RTC

      rtcDelay(150);

      // wait for clock ready
      while ((RTC_Read (RTC0XCN) & 0x10)== 0x00);

      rtcDelay(150);                       // wait 1 ms

      // wait for cap ready
      while ((RTC_Read (RTC0XCF) & 0x40)== 0x00);

      RTC_Write (RTC0XCN, 0x40);          // disable bias doubling

      //RTC_Write (RTC0CN, 0xC0);          // Enable Missing clock detector

      RTC_ClearCapture ();                // clear CAPTUREn registers
      RTC_ClearAlarm ();                  // clear ALARMn registers

      RTC_Write (RTC0CN, 0xC2);           // transfer capture to clock
      RTC_Write (RTC0CN, 0xD0);           // enable RTC run
      Is_RTC_Ready = TRUE;
   }
}