回复 20楼 仙猫 的帖子
51和其他MCU相比,是很慢的,12分频,
那具体看中断服务程序怎么写了?
PUSH ACC
PUSH PSW
PUSH ...
PUSH ...
SERVR:
POP ...
POP ...
POP PSW
POP ACC
所以要力求压缩中断服务程序,如果是中断服务只对一个byte变量+1,在80步之内不会做不到吧?
RE ::OK
来看看我公司的做的一个项目吧,也是RTC的中断.
void TimeBase() /* 0.5s interrupt timer program */
{
uchar Temp,i;
_intc1 &= ~D6; // clear this interrupt flag ,deny come back again .
_mfic &= ~D5;
if(rWakeTimer) rWakeTimer--;
if(rTimerAutoTran) rTimerAutoTran--; //2s
if(rFlag3&0x0f){
if(rRetryCountCur) rRetryCountCur--;
}
if(++rMinCount >= 120) {
rMinCount = 0;
if(rTimeTranTest) rTimeTranTest--;
}
if(rFlag3&0xF0)
{
if(rRetryCountLight) rRetryCountLight--;
}
//--------------------------
rFlag2 ^= cFlashdot;
if(rKeyValue == cKey_SetID || rKeyValue == cKey_SetRetry || rKeyValue == cKey_DEL || rKeyValue == cKey_TranManu)
{
rTimeHold++;
}
if( rKeyValue ==cKey_DevA || rKeyValue ==cKey_DevB || rKeyValue ==cKey_DevC || rKeyValue ==cKey_DevD )
{
rTimeHold++;
}
if(rScreenReturnCnt<60) //0.5s*60=30s return timer
{
rScreenReturnCnt++;
}
rCurrentSecond++;
if(rCurrentSecond==120){ //1 minute
rZeroTransFlag=1;
rCurrentMinute++;
rCurrentSecond=0;
if(rCurrentMinute==60){ //1 hour
rCurrentHour++;
rCurrentMinute=0;
if(rCurrentHour==24){
rCurrentSecond=0;
rCurrentMinute=0;
rCurrentHour=0;
}
}
}
}
这样就可能达不到了.必须把SECOND++,MINUTE++,HOUR++等搬到主程序去处理,也就是我前面说过的压缩中断服务程序.
[
本帖最后由 jxb01033016 于 2009-9-21 18:06 编辑 ]