RTC_B の使用
XIN は 32.768 kHz のクロック ソース (発振器ではない) に接続されています。
発振器がないため、XIN バイパスが使用されます。
初期コードは次のとおりです。
//Calendar mode, BCD coded, stop rtc, hourly interrupt
RTCCTL01 = RTCTEV_0 + RTCHOLD;
//no calibration
RTCCTL23 = 0;
//prescale setup
RTCPS0CTL = 0; // disable PS0 interrupts
//clear calendar
RTCHOUR = 0;
RTCMIN = 0;
RTCSEC = 0;
RTCDAY = 0;
RTCMON = 0;
RTCYEAR = 0;
//enable RTC
RTCCTL01 &= ~RTCHOLD;
この後、RTCRDY ビットがセットされるのを待ちますが、セットされません。
while( !(RTCCTL01 & RTCRDY) );
クロックは次のように構成されていることに注意してください。
// Enable XT1(32.768kHz) and XT2(4MHz) clock ports
XT1_XT2_PORT_SEL |= (XT1_ENABLE + XT2_ENABLE);
XT1_Bypass();
ret = SetVCore(3); // Set Vcore to accommodate for max. allowed
LFXT_Start(XT1DRIVE_3); // Enable XT1 and maximize drive strength
//! \note The system clock is derived from the internal reference clock,
//! which is set to 32768.
Init_FLL_Settle(MCLK_TICKPERSEC/1000, MCLK_TICKPERSEC/32768);