你好,我在使用2812定时器0定时时,我要求定时十分钟,在刚开始前几个小时内,还可以满足定时时间,但是一般五个小时以后,就会出现一次定时时间不准,可是接下来又可以准确定时十分钟,怎么回事?
配置是主频150 ,TPR.all = 119, temp=150*5000000
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.
你好,我在使用2812定时器0定时时,我要求定时十分钟,在刚开始前几个小时内,还可以满足定时时间,但是一般五个小时以后,就会出现一次定时时间不准,可是接下来又可以准确定时十分钟,怎么回事?
配置是主频150 ,TPR.all = 119, temp=150*5000000
程序主要就是,我通过定时器定时开启AD中断,然后将采样值发送出去。
interrupt void ADCINT_ISR(void) // ADC中断函数
{
//读取转换结果
adc[0]=((float)AdcRegs.RESULT0)*3.0/65520.0+adclo; //读取ADCINA0通道采样结果
adc[1]=((float)AdcRegs.RESULT1)*3.0/65520.0+adclo; //读取ADCINB0通道采样结果
adc[2]=((float)AdcRegs.RESULT2)*3.0/65520.0+adclo; //读取ADCINA3通道采样结果
SampleValue0[SampleCount]= adc[0];
SampleValue7[SampleCount]= adc[1];
SampleCount++;
if(SampleCount>=MaxSampleNum-5)
{
EvaRegs.T1CON.bit.TENABLE=0; //关闭T1计数
SampleCount=0;
flag=1;
}
AdcRegs.ADCTRL2.bit.RST_SEQ1=1;
AdcRegs.ADC_ST_FLAG.bit.INT_SEQ1_CLR=1;
PieCtrl.PIEACK.all=PIEACK_GROUP1;
EINT;
}
interrupt void TINT0_ISR(void) // CPU-Timer0中断函数
{
EvaRegs.T1CON.bit.TENABLE=1; //启动T1计数
CpuTimer0Regs.TCR.bit.TIF=1; //清除定时器中断标志位
PieCtrl.PIEACK.bit.ACK1=1; //响应同组其他中断
EINT; //开全局中断
}
CPU Time历程有个Bug,需要修复一下:下面那行 Jones Bug fixed
void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
{
Uint32 temp;
// Initialize timer period:
Timer->CPUFreqInMHz = Freq;
Timer->PeriodInUSec = Period;
temp = (long) (Freq * Period);
Timer->RegsAddr->PRD.all = temp-1;//Jones bug fixed
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
Timer->RegsAddr->TPR.all = 0;
Timer->RegsAddr->TPRH.all = 0;
// Initialize timer control register:
Timer->RegsAddr->TCR.bit.TSS = 1; // 1 = Stop timer, 0 = Start/Restart Timer
Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
Timer->RegsAddr->TCR.bit.SOFT = 0;
Timer->RegsAddr->TCR.bit.FREE = 0; // Timer Free Run Disabled
Timer->RegsAddr->TCR.bit.TIE = 1; // 0 = Disable/ 1 = Enable Timer Interrupt
// Reset interrupt counter:
Timer->InterruptCount = 0;
}
跟楼主一块调试的,我再补充下楼主的现象哈,就是无论定时是10分钟还是30分钟,每过4小时45分钟20秒 DSP2812就重启复位一次,时间间隔很准时,不知道是不是程序问题,还望给例举下可能出现此问题的原因?谢谢
查看门狗,具体喂狗的时间间隔。
或者是否程序有溢出的现象,例如进入了非法中断,比如Stack空间是否足够。
建议:
先关闭看门狗,跑几个小时,看是否进入了非常中断,如果进入了,查原因。