This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
程序:
RTC_Init();
while (1)
{
P8OUT ^= BIT3;
__bis_SR_register(LPM4_bits+GIE);
}
///////////////////////////////////////////////////////////////////////////////////////
#pragma vector=RTC_VECTOR
__interrupt void RTC_B_ISR()
{
switch (RTCIV)
{
case 2:
P8OUT ^= BIT2;
__bic_SR_register_on_exit(LPM4_bits+GIE);
break;
}
}
}
///////////////////////////////////////////////////////////////
void RTC_Init(void)
{
// Setup Clock
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
while(BAKCTL & LOCKBAK) // Unlock XT1 pins for operation
BAKCTL &= ~(LOCKBAK);
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
RTCCTL01 |= RTCRDYIE + RTCBCD + RTCHOLD; // BCD mode, RTC hold, enable RTC
// event interrupt
RTCYEAR = 0x2011; // Year = 0x2011
RTCMON = 0x10; // Month = 0x10 = October
RTCDAY = 0x07; // Day = 0x07 = 7th
RTCDOW = 0x05; // Day of week = 0x05 = Friday
RTCHOUR = 0x11; // Hour = 0x11
RTCMIN = 0x59; // Minute = 0x59
RTCSEC = 0x45; // Seconds = 0x45
RTCCTL01 &= ~(RTCHOLD); // Start RTC calendar mode
}
////////////////////////////////////////////////////
该程序运行时,只要进入RTC中断一次,再只要执行完while循环的__bis_SR_register(LPM4_bits+GIE)后就会进RTC中断,好像RTC中断标志位清除不了。DEBUG的时候是正常的。换别的定时器中断源也是正常的。独独使用RTC中断的时候出现这种情况。
感觉好像是单片机的硬件BUG啊。实在想不通;
If the backup-supplied subsystem is powered by the secondary supply VBAT, the access and control to
modules located in the subsystem is restricted:
• The data stored in the backup RAM is retained but cannot be accessed.
• The RTC, if enabled, together with the 32-kHz crystal oscillator continue to operate but the time and
date information cannot be accessed.
• Changes to the LF crystal oscillator setting in the clock system do not take effect
程序初始化时 BAKCTL |= BAKDIS;禁用backup-supplied subsystem也可以解决此问题