【填空题】1、可控秒表(按键控制)的设计,根据电路补充程...
【填空题】1、可控秒表(按键控制)的设计,根据电路补充程序 要求: 可控秒表的设计(按键控制)S1键按下启动秒表工作,秒表每间隔1S,显示加1,当加到60时,数码管显示0,从0开始继续加1。S2键按下,秒表暂停工作,/*-------------------第一部分:预处理命令-----------------*/ <reg51.h> //包含头文件reg51.h /*--------------第二部分:定义全局变量或常量----------*/ sbit com1=P3^0; sbit com2=P3^1; unsigned char dm[]={ ,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//共阳数码管0-9对应段码 unsigned char c1,miao=50; /*-----第三部分:函数原型申明及函数定义-----*/ void ys( ) { while(t--); } void zdcsh()//中断初始化程序的编写 { TH0=(65536- )/256;//T0定时时间为10000us TL0=(65536- )%256; //设置T0为工作方式1,定时器使用 //定时器T0中断允许 EX0=1;//外部中断0中断允许 EX1=1;//外部中断1中断允许 EA=1;//总中断允许 //外部中断0中断触发方式为边沿触发方式 //外部中断1中断触发方式为边沿触发方式 PX1=1;PX0=1;PT0=0;//外部中断1、外部中断0中断优先级高,定时器T0中断优先级低 TR0=0;//T0关闭 } void xs()//显示函数 { com1=1;com2=0;//选中1号数码管 P2=dm[ ];//显示变量miao的十位 ys(1000); //关闭显示,消影 com1=0;com2=1;//选中2号数码管 P2=dm[ ];//显示变量miao的个位 ys(1000); P2=0xff;//关闭显示,消影 } void main() { //调用中断初始化函数 while( ) { xs(); } } void tozd( ) interrupt //T0中断函数 { TH0=(65536- )/ ; TL0=(65536-10000)%256; c1++;//5万us计算器加1 if( )//1S时间到 { miao++; if( ) miao=0;//当秒计数到60,回到0 } } } void wbzd0() //外部中断0对应中断函数 { //启动定时器T0 } void wbzd1() //外部中断1对应中断函数 { TR0=0;//关闭定时器T0 }