历史上的今天
今天是:2024年12月13日(星期五)
2021年12月13日 | 单片机10秒秒表
2021-12-13 来源:eefocus
硬件连接:
代码:
#include #define uchar unsigned char #define uint unsigned int sbit K1 = P3^7; uchar i,Second_Counts,Key_Flag_Idx; bit Key_State; uchar DSY_CODE[]= { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f }; void DelayMS(uint ms) { uchar t; while(ms--) { for(t=0;t<120;t++); } } void Key_Event_Handle() { if(Key_State == 0) { Key_Flag_Idx=(Key_Flag_Idx+1)%3; switch(Key_Flag_Idx) { case 1:EA=1;ET0=1;TR0=1;break; case 2:EA=0;ET0=0;TR0=0;break; case 0:P0=0x3f;P2=0x3f;i=0;Second_Counts=0; } } } void main() { P0 = 0x3f; P2 = 0x3f; i = 0; Second_Counts = 0; Key_State = 1; TMOD = 0x01; TH0 = (65535-50000)/256; TL0 = (65535-50000)%256; while(1) { if(Key_State != K1) { DelayMS(10); Key_State = K1; Key_Event_Handle(); } } } void DSY_Refresh() interrupt 1 { TH0 = (65535-50000)/256; TL0 = (65535-50000)%256; if(++i==2) { i = 0; ++Second_Counts; P0 = DSY_CODE[Second_Counts/10]; P2 = DSY_CODE[Second_Counts%10]; if(Second_Counts == 100) Second_Counts = 0; } }
上一篇:按键状态led显示
下一篇:单片机蜂鸣器生日快乐歌
史海拾趣
|
哪里能够购买到《嵌入式实时操作系统VxWorks及其开发环境Tornado》? 请问哪里能够购买到《嵌入式实时操作系统VxWorks及其开发环境Tornado》作者: 孔祥营/柏桂枝 ?好像这本书绝版了,网上书店都是缺货啊!请给予帮助,万分感谢!!!… 查看全部问答> |
|
福利体系:18% 住房补贴,7% 交通补贴+600,年底双薪,年终2.5-3个月工资 奖金,另外每年3000元左右 现金保单,30万 人生意外险和重大疾病险。 公司为个人缴纳的保险分为两种形式,如果有居住证或户口在上海的,公司缴纳城保,那么住房补贴是四金 ...… 查看全部问答> |
|
我使用vivi的load flash wince u命令,将wince烧写到板上的flash时,格式化的时候出现几个error, 然后也正常格式化完毕,刚刚把wince烧写到板上时,wince正常启动,因为我没有断过电, 重启之后flash上刚刚烧写的wince就不见了,不能正常启动 ...… 查看全部问答> |
|
ERROR:EDK - INFO:Security:56 - Part \'xc6slx9\' is not a WebPack part. INFO:Security:60 - The XILINXD_LICENSE_FILE environment variable is set to \'C:\\Xilinx\\Xilinx.lic\'. INFO:Security:62 - T ...… 查看全部问答> |




