使用 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);