四川师范大学成都学院电子工程系课程设计报告
}
//定时1s
tomer1() interrupt 3 using 2 { count++; //1s到
if(count == 1) {
p26 = 1; p27 = 0; }
if(count == 25) {
p26 = 0; p27 = 0; }
if(count == 38) {
p26 = 0; p27 = 1; }
if(count == 49) {
p26 = 0; p27 = 0; }
if(count == 60)
{
24
四川师范大学成都学院电子工程系课程设计报告
count = 0; displayjia();
if(mstime == chushizhi) {
p30 = 1; TR0 = 0; TR1 = 0;
} }
}
int0() interrupt 0 using 3 { delay(15); if(p32 == 0) stopp = 0;
}
void Init() { p26 = 0; p27 = 0; p30 = 0; p33 = 0; TMOD = 0x61; //T0方式1定时,T1方式2计数 TH0 = 0x3c;
//预置定时初值
TL0 = 0xb0; TH1 = -7; TL1 = -7; ET0 = 1;
EX0 = 1;
25
四川师范大学成都学院电子工程系课程设计报告
IT0 = 0; ET1 = 1; TR0 = 0; TR1 = 0; EA = 1;
}
void settime(void) { while(stopp) {
if(p24 == 0) { delay(50); if(p24 == 0) { displayjia();
}
}
if(p25 == 0) { delay(50); if(p25 == 0) { displayjian();
}
}
display(); }
chushizhi = mstime;
mstime = 0;
26
四川师范大学成都学院电子工程系课程设计报告
TR0 = 1; TR1 = 1;
}
#include\
void main() { uint i;
Init(); //程序初始化 settime(); //设定定时时间
while(1) {
display();
//显示时间 if(mstime == chushizhi) {
for(i = 0;i < 200;i++) { display(); //显示时间
delay(1); if(i == 199) { p30 = 0; mstime = 0; count = 0; stopp = 1; settime();
if(mstime == chushizhi) { for(i = 0;i < 200;i++)
{
27
} } }
}
}
四川师范大学成都学院电子工程系课程设计报告
display(); //显示时间
delay(1); if(i == 199) { p30 = 0;
}
}
}
28