|
发表于 2023-5-16 11:43:21
|
显示全部楼层
void timer0() interrupt 1
{
TH0=(65536-50000)/256;//重新赋初值
TL0=(65536-50000)%256;
a++;
b++;//中断一次变量aa的值加1
if(b==2) //中断2次后,定时时间为2*50ms=100ms=0.01s,将变量temp0的值加1
{
b=0;
temp0++;
if(temp0==100) //秒表到达1s后回零
{
temp0=0;
}
baifen=temp0%100/10;
shifen=temp0%10; //分离十分位和百分位
}
if(a==20) //中断20次后,定时时间为20*50ms=1000ms=1s,将变量temp1的值加1
{
a=0;
temp1++;
if(temp1==60) //秒表到达60s后回零
{
temp1=0;
}
shi=temp1%100/10;
ge=temp1%10; //分离个位和十位
}
} |
|