当前位置:网站首页>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 .
边栏推荐
- Inverse yuan (I'll add these words if there are too many people using the name)
- regular expression
- [unity Editor Extension] unity makes its own exclusive editor panel
- Uniapp wechat applet login (authorize wechat first and then mobile phone number) - (1)
- Response assertion of JMeter interface test
- Interface (collection/map) - implementation and comparison of interfaces
- Sword finger offer 48 The longest substring without repeated characters
- 正则、扩展表达式,sed文本处理器与awk工具、用脚本改IP地址
- Lintcode 366:fibonacci Fibonacci sequence
- Firewalld 防火墙
猜你喜欢

HCIA_NAT实验

Leetcode buckle classic topic - 82 Maximum rectangle in column chart

正则表达式

PXE automated installation

Response assertion of JMeter interface test

10.系统安全及应用

Inverse yuan (I'll add these words if there are too many people using the name)

Flask template injection

Cocoon breaking and rebirth of 3D NFT: caduceus decentralized edge rendering technology

Understand HTTP cache in 30 minutes
随机推荐
Network layer protocol and IP packet format (detailed)
RHCE-ansible-第一次作业
[tools] unity quickly starts to make the artifact tilemap of 2D and 2.5D games
Use of sqlmap
General knowledge of network (detailed)
Understand inheritance, polymorphism, abstraction and their concepts
The JMeter BeanShell implementation writes the parameterized data generated by the request to the file
Static routing (detailed)
Dirty reading, unreal reading, non repeatable reading
Zabbix6.0通过iDRAC,IMM2监控DELL,IBM服务器硬件
Circular statements and functions of shell scripts
Performance test implementation specification Guide
squid代理服务部署
[unity Editor Extension] quickly locate the specified files and paths of resources and scripts
Convert string to integer
Leetcode buckle classic topic - 82 Maximum rectangle in column chart
CTFHub----RCE
Interface (collection/map) - implementation and comparison of interfaces
Leetcode 70:Climbing Stairs
安装软件提示无法定位程序输入点AddDllDirectory于动态链接库Kernel32.dll上(文末有下载地址)
