单片机 求15分钟的计时程序

15 或30 分钟的计时程序 我在编一个关于洗衣机定时器的计时程序

#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uint count,second;
void main(void)
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
EA=1;
while(1)
{
在这里你可以做其他处理
}
}
void timet0(void) interrupt 1 using 0
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
second++;
if(second==900)
second=0;
}
}

程序给出,望查收!
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-07-08
先写一个1ms的程序,再写一个FOR语句,循环1000次。就得到1s的计时程序。
接下来就好办了。
根据你要的时间来写FOR语句就好,注意不要溢出。
第2个回答  2010-07-08
那是倒计时了吧
第3个回答  2010-07-08
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uint count,second;
void main(void)
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
EA=1;
while(1);
}
void timet0(void) interrupt 1 using 0
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
second++;
if(second==15)
second=0;
}
}