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匹配中断问题



使能定时器的RTC模式后,会给它加载一个初始值,然后有一个中断处理函数进行匹配,但是过了一段时间后,我需要精确地时间,然后给RTC重新加载一个初始值,但是中断为什么还是按原先的加载的初始值在匹配,进行一秒一个中断,我确定初始值和后面加载值都加载进去了。程序附下: 初始化函数 void timerInitRTC(unsigned long ulVal) {
SysCtlPeriEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeTimer( GPIO_PORTD_BASE, GPIO_PIN_4);
SysCtlPeriEnable(SYSCTL_PERIPH_TIMER3);  
TimerConfigure(TIMER3_BASE, TIMER_CFG_RTC);  //设置为RTC模式
GPIOPinConfigure(GPIO_PD4_T3CCP0);//把PD4作为频率输入
TimerLoadSet(TIMER3_BASE,  TIMER_A, ulVal);
TimerMatchSet(TIMER3_BASE, TIMER_A, 1 + ulVal);

//使能定时器中断 TimerIntEnable(TIMER3_BASE, TIMER_A);  
IntEnable(INT_TIMER3A);
IntMasterEnable( );
  //使能RTC计数
TimerRTCEnable(TIMER3_BASE);  
TimerEnable(TIMER3_BASE,  TIMER_A);  
}
中断处理函数 void Timer3A_ISR(void) { uint32_t ulStatus;   uint32_t ulVal;   uint32_t ucVal; ulStatus = TimerIntStatus(TIMER3_BASE, true); TimerIntClear(TIMER3_BASE, ulStatus); if (ulStatus & TIMER_RTC_MATCH) {   ulVal = TimerValueGet(TIMER3_BASE,TIMER_A);  //读取当前RTC计时器值    TimerMatchSet(TIMER3_BASE, TIMER_A, 1 + ulVal);  // 重新设置RTC匹配值   
    ucVal = GPIOPinRead(GPIO_PORTK_BASE, GPIO_PIN_2 ); // 反转LED灯     GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_2, ~ucVal);    }
}

  • 是中断为什么还是按原先的加载的初始值在匹配,进行一秒一个中断,我确定初始值和后面加载值都加载进去了。你查看寄存器了么?怎么确定加载进去了呢?如果加载进去了,肯定是按照加载后的运行的。