全文预览

单片机定时闹钟设计

上传者:读书之乐 |  格式:doc  |  页数:15 |  大小:0KB

文档介绍
harРuchar code segcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //0~9Рuchar code segcode2[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef}; //带小数点0~9Рuchar buffer[]={0,0,0,0};Рuchar buffer2[]={0,0,0,0}; //闹钟Рuint hou,min,sec;Рuint hou2,min2=0; //闹钟Рuint i,status,num;Рbit flag,flag1,keyrelease;Рsbit alarm=P3^7;Рuchar buf,keyinput;Рvoid display();Рvoid keyscan();Рvoid keyprocess(unsigned char key);Рvoid delayMS(uint t)Р{Рuint i;Рwhile(t--)Рfor(i=0;i<125;i++);Р}Рvoid init() //初始Р{Рkeyrelease=1;Рbuf=0x0f;Рmin2=2; //避免打开就鸣叫,设闹钟分=2Рflag=0;РTMOD=0x21;РTH0=(65536-5000)/256;РTL0=(65536-5000)%256;РTH1=0xfd;РTL1=0xfd;РSCON=0x50;РPCON=0x00;РTR1=1;РIP=0x10;РTR0=0;РIE=0x92; //开总、定时器0,串口中断Р}Рvoid main()Р{Рinit();Рwhile(1)Р{Рkeyscan();Рdisplay();Рif(hou==hou2&&min==min2&&sec<5) //仿真使用Р{

收藏

分享

举报
下载此文档