Пример #1
0
void InitializeRealTimeClock( void )
{
	Timer_Initialise();

  // stop it
  RTCCTL01 = RTCHOLD;

  // use calibration data to adjust real time clock frequency
  if ( QueryCalibrationValid() )
  {
    signed char RtcCalibrationValue = GetRtcCalibrationValue();
    
    if ( RtcCalibrationValue < 0 )
    {
      RtcCalibrationValue = -1 * RtcCalibrationValue;
      RTCCTL2 = RtcCalibrationValue & RTCCAL_VALUE_MASK;
    }
    else
    {
      RTCCTL2 = RtcCalibrationValue & RTCCAL_VALUE_MASK;
      /* adjust up */
      RTCCTL2 |= RTCCALS;
    }
    
  }
  
  
  // Set the counter for RTC mode
  RTCCTL01 |= RTCMODE;

  // set 128 Hz rate for prescale 0 interrupt
  RTCPS0CTL |= RT0IP_7;

  // enable 1 pulse per second interrupt using prescale 1
  RTCPS1CTL |= RT1IP_6 | RT1PSIE;

  // 1 Hz calibration output
  RTCCTL23 |= RTCCALF_3;

  // setting the peripheral selection bit makes the other I/O control a don't care
  // P2.4 = 1 Hz RTC calibration output
  // Direction needs to be set as output
  RTC_1HZ_PORT_SEL |= RTC_1HZ_BIT;  
  RTC_1HZ_PORT_DIR |= RTC_1HZ_BIT;  

  // These calls are to asm level patch functions provided by 
  // TI for the MSP430F5438
  SetRTCYEAR((unsigned int)0x07db);
  SetRTCMON((unsigned int)5);
  SetRTCDAY((unsigned int)23);
  SetRTCDOW((unsigned int)5);
  SetRTCHOUR((unsigned int)23);
  SetRTCMIN((unsigned int)58);
  SetRTCSEC((unsigned int)0);


  // Enable the RTC
  RTCCTL01 &= ~RTCHOLD;  
}
Пример #2
0
//***************************************************************************//
//                                                                           //
//                 初始化RTC                                                 //
//                                                                           //
//***************************************************************************//
void Init_RTC(void)
{
  RTCCTL01 = RTCSSEL_0 + RTCMODE                     ; // 时钟模式,十六进制格式
  SetRTCYEAR(2010)                                   ; 
  SetRTCMON(10)                                      ;
  SetRTCDAY(24)                                      ;
  SetRTCDOW(0)                                       ;
  SetRTCHOUR(10)                                     ;
  SetRTCMIN(9)                                       ;
  SetRTCSEC(45)                                      ;
}
Пример #3
0
void halRtcSet(RTC_DATA* pRtcData)
{
  // Stop the RTC
  RTCCTL01 |= RTCHOLD;    

  // These calls are to asm level patch functions provided by TI for the MSP430F5438
  tWordByteUnion temp;
  temp.byte.b0 = pRtcData->Year & 0xFF;
  temp.byte.b1 = (pRtcData->Year >> 8) & 0xFF;
  SetRTCYEAR((unsigned int)(temp.word));
  SetRTCMON((unsigned int)(pRtcData->Month));
  SetRTCDAY((unsigned int)(pRtcData->DayOfMonth));
  SetRTCDOW((unsigned int)(pRtcData->DayOfWeek));
  SetRTCHOUR((unsigned int)(pRtcData->Hour));
  SetRTCMIN((unsigned int)(pRtcData->Minute));
  SetRTCSEC((unsigned int)(pRtcData->Second));
  
  // Enable the RTC
  RTCCTL01 &= ~RTCHOLD;  
}
Пример #4
0
static void SaveTime(NumberEntry *timeEditor)
{
	SetRTCHOUR(timeEditor->RangeValueAt(0, 2));
	SetRTCMIN(timeEditor->RangeValueAt(3, 2));
	SetRTCSEC(timeEditor->RangeValueAt(6, 2));
}