当前位置:网站首页>Dynamic display of digital tube stopwatch of single chip microcomputer
Dynamic display of digital tube stopwatch of single chip microcomputer
2022-07-19 02:46:00 【chip1234】
Based on MCU STC89C52RC, Use timer 1, Adopt the method of dynamic scanning , The stopwatch is displayed in the first three digits of the nixie tube , Accurate to 0.01 second , such as 5.03 second , Cycle all the time .
First, set the display refresh rate to 6ms, Every time 2ms Refresh 1 A digital tube , Every time 10ms Calculate the time .
Time displayed 3 Bits are structured .
The first is the circuit structure , Adopt common cathode digital tube ,74573 Latch and 138 Decoder .
Then there is the program code
/********************************* @title:Óö¨Ê±Æ÷1ºÍ¶¯Ì¬É¨Ãè·½·¨£¬ÔÚÊýÂë¹ÜµÄǰÈýλ ÏÔʾ³öÃë±í£¬¾«È·µ½1%Ã룬¼´ºóÁ½Î»ÏÔʾ1%Ã룬 һֱѻ· @MCU:STC89C52 @name: Wang Yongxing @date: 2014.08.18 **********************************/ # include "MacroAndConst.h" # include <stc89c5xrc.h> # include <intrins.h> sbit LE_74573 = P1^0; sbit LSA_74LS138 = P2^2; sbit LSB_74LS138 = P2^3; sbit LSC_74LS138 = P2^4; //¹²ÒõÊýÂë¹Ü0-F dp-a£º0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, //0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71 char SegLed[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; void InitTimer1(void); void SegLedDisplay(void); struct { char sec0;//Ãë±í×î¸ßλ char sec1;//Ãë±íСÊýµãºóµÚһλ char sec2;//Ãë±íСÊýµãºóµÚ¶þλ }sec; uchar num = 7; char ms10flag = 0; int main(void) { InitTimer1();//¶¨Ê±Æ÷0³õʼ»¯ EA = 1;//ʹÄÜϵͳ×ÜÖÐ¶Ï LE_74573 = 1; sec.sec0 = 0; sec.sec1 = 0; sec.sec2 = 0; while(1) {} return 0; } void InitTimer1(void) { TMOD = 0x10;//¶¨Ê±Æ÷0£¬16λ¶¨Ê±Æ÷ TH1 = 0xF8;//¶¨Ê±Îª2ms£¬50*1000us TL1 = 0x2F; ET1 = 1; //ʹÄܶ¨Ê±Æ÷0µÄÖÐ¶Ï TR1 = 1;//¶¨Ê±Æ÷0¿ªÊ¼ÔËÐÐ } void Timer1Isr() interrupt 3 using 1 { TH1 = 0xF8;//¶¨Ê±Îª2ms£¬50*1000us TL1 = 0x2F; ms10flag++; if(ms10flag == 5) { ms10flag = 0; P0 = 0X00;//Çå³ýÏÔʾ if(++sec.sec2 == 10)//¼ÆËãʱ¼ä { sec.sec2 = 0; if(++sec.sec1 == 10) { sec.sec1 = 0; if(++sec.sec0 == 10) { sec.sec0 = 0; } } } } SegLedDisplay(); } void SegLedDisplay(void) { switch(num) { // case 0:LSC_74LS138 = 0;LSB_74LS138 = 0;LSA_74LS138 = 0;break; // case 1:LSC_74LS138 = 0;LSB_74LS138 = 0;LSA_74LS138 = 1;break; // case 2:LSC_74LS138 = 0;LSB_74LS138 = 1;LSA_74LS138 = 0;break; // case 3:LSC_74LS138 = 0;LSB_74LS138 = 1;LSA_74LS138 = 1;break; // case 4:LSC_74LS138 = 1;LSB_74LS138 = 0;LSA_74LS138 = 0;break; case 5: { LSC_74LS138 = 1; LSB_74LS138 = 0; LSA_74LS138 = 1; P0 = SegLed[sec.sec2]; break; } case 6: { LSC_74LS138 = 1; LSB_74LS138 = 1; LSA_74LS138 = 0; P0 = SegLed[sec.sec1]; break; } case 7: { LSC_74LS138 = 1; LSB_74LS138 = 1; LSA_74LS138 = 1; P0 = SegLed[sec.sec0]; P0 |= 0x80;//ÏÔʾСÊýµã break; } } if(--num == 4) { num = 7; } }I don't know what happened ,keil The Chinese comments of the code are all garbled .
There is a problem in the middle , To show the decimal point , The topmost display uses the statement
P0 = 0x80|SegLed[sec.sec0];
Digital tube with the highest display of seconds , stay 0,6,9 The display is abnormal , Full flash
Later, the sentence was changed to
P0 = SegLed[sec.sec0];
P0 |= 0x80;//ÏÔʾСÊýµãFangzhengchang , But I still don't know why . But the effect is very good .
边栏推荐
- "Visual C # from getting started to mastering" personal learning arrangement
- C语言回调函数 & sprinf 实际应用一例
- Method of JMeter connecting to database
- MySQL初探
- HCIA静态综合实验
- Simple use case writing specification
- [solution] the local Group Policy Editor (gpedit.msc) in Win 11 cannot be opened
- Detailed explanation of metauniverse public chain caduceus: a creative platform specially built for metauniverse application
- Find() (if the name is used by too many people, I will add words)
- shell脚本之循环语句与函数
猜你喜欢

10.系统安全及应用

shell脚本之条件语句
![[unity development tips] unity mixer mixer controls global volume](/img/dd/12b307d5e69609c1471bad8174c20e.png)
[unity development tips] unity mixer mixer controls global volume

【瑞吉外卖⑩】Linux 粗略学习 & Redis 粗略学习

Decentralized edge rendering meta universe protocol cadeus was invited to attend the cbaia 2022 summit to enable more Web3 application scenarios with technology

Getting to know Alibaba cloud environment construction for the first time: unable to connect remotely, and having been in the pit: the server Ping fails, FTP is built, the server builds the database,
![[solved] after referring to the local MySQL and forgetting the password, [server] --initialize specified but the data directory has files in it Aborti](/img/a8/2daa2c0d834f1986c8421bf5138c7e.png)
[solved] after referring to the local MySQL and forgetting the password, [server] --initialize specified but the data directory has files in it Aborti
![[unity Editor Extension] unity makes its own exclusive editor panel](/img/67/12a4ab5167d4a5fc2aaba5220c8df9.png)
[unity Editor Extension] unity makes its own exclusive editor panel

shell脚本之循环语句与函数

摇摆摇摆~防火墙
随机推荐
BeanShell script gets the current time
No, no, No. yesterday, someone really didn't write binary enumeration
[unity Editor Extension] find all objects of a script attached in the scene and resources
Project Performance Optimization Practice: solve the white screen problem of the home page, customize the loading animation to optimize the first screen effect
时间管理方法的反思与探讨
Leetcode 198:House Robber
数组、冒泡的认识
Leetcode --- one question per day
如果猎人用枪打兔子
MySQL备份和恢复
Various development tools
通过Xshell7使用rz,sz命令上传下载文件
Lintcode 366:fibonacci Fibonacci sequence
单片机之数码管秒表的动态显示
Common English business mail phrases
Brief introduction of Feature Engineering and its implementation of sklearn
登录功能的测试点大全
Convert string to integer
Understanding of array and bubbling
After unity imports the FBX model, the rotation and position of the object will change automatically at runtime
