unsigned g_TIME_COUNT = 0;
void main()
{
unsigned temp;
init_timer0(); //T0定时100ms
while(1)
{
temp = keyboard();
if(temp !=0) //假设无按键按下返回0
{
g_TIME_COUNT = 0;
}
if(g_TIME_COUNT > 100)
{
显示0000
g_TIME_COUNT = 101;
}
}
}
void T0_interrupt()interrupt 1
{
TF0 = 0;
g_TIME_COUNT ++;
}
差不多这样吧,至于选用何种计时方式,啥时候使能T0更准确,楼主自己弄吧
|