当前位置:网站首页>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 .
边栏推荐
- 解决WIN10连接共享打印机出现0x00000709的错误
- Detailed explanation of caduceus project of metauniverse public chain (I): project concept and technical framework of caduceus metaverse protocol
- [unity Editor Extension] displays the memory size of all files in the resource directory
- PHP pseudo protocol for command execution
- Inverse yuan (I'll add these words if there are too many people using the name)
- 性能瓶颈定位XMind
- DHCP原理与配置
- RHCE-ansible第二次作业
- Sigaga
- Various development tools
猜你喜欢

regular expression

InnoDB, MySQL structure, and the difference between the three kinds of deletion

squid代理服务部署

LAMP平台部署及应用

单片机之数码管秒表的动态显示

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

The solution to the bounce and offset of unity3d game characters when jumping to the ground

Zabbix6.0通过iDRAC,IMM2监控DELL,IBM服务器硬件

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,

HCIA静态综合实验
随机推荐
Dynamic programming problem - Small Soldiers rush forward
10.系统安全及应用
[unity development tips] unity mixer mixer controls global volume
Test knowledge preparation
Interpretation of concurrent virtual users, RPS and TPS
解决WIN10连接共享打印机出现0x00000709的错误
摇摆摇摆~防火墙
Response assertion of JMeter interface test
The jstat command checks the GC status of the JVM
Leetcode 1: Two Sum
[hsjframework] unity time management timemanger timer
Shell programming specifications and variables
shell脚本之条件语句
Brief introduction of Feature Engineering and its implementation of sklearn
HCIA_RIP实验
MySQL差删改查用户登录修改密码
PXE自动化安装
Uni app wechat applet ordering system [another order] page Jump
How to add software shortcuts to the right mouse button list
No, no, No. yesterday, someone really didn't write binary enumeration