#include
Keywords:Tm1639
Reference address:Tm1639 assembly driver
sbit DIO=P1^2; sbit CLK=P1^1; sbit STB=P1^0; #define DIG0 0xc0 #define DIG1 0xc2 #define DIG2 0xc4 #define DIG3 0xc6 #define DIG4 0xc8 #define DIG5 0xca #define DIG6 0xcc #define DIG7 0xce #define LEVEL_OFF 0x80 #define LEVEL_1 0x88 #define LEVEL_2 0x89 #define LEVEL_4 0x8a #define LEVEL_10 0x8b #define LEVEL_11 0x8c #define LEVEL_12 0x8d #define LEVEL_13 0x8e #define LEVEL_14 0x8f #define MD_WRITE 0x40 #define MD_AUTO MD_WRITE #define MD_NORMAL MD_WRITE #define MD_READKEY 0x42 #define MD_FIX 0x44 #define MD_TEST 0x48 typedef unsigned char uint8; typedef unsigned int uint16; uint16 key; code uint8 shuzu[17] ={ 0x3F,0x06,0x5B,0x4F, 0x66,0x6D,0x7D,0x07, 0x7F,0x6F,0x77,0x7c, 0x39,0x5e,0x79,0x71, 0x00, }; void xianshi(uint8 x,uint8 led,uint8 level); void start(); void chushi(); void ClearAll(); void KeyRead(uint16 *key); void indate(unsigned char input) { unsigned int i; STB=0; for(i=0;i<8;i++) { CLK=0; if((input & 0x01)!=0) PART=1; else PART=0; CLK=1; input=input>>1; } } unsigned char outdate() { unsigned char i,out=0; PART = 1; STB=0; for(i=0;i<8;i++) { CLK=0; out=out>>1; if(DIO == 0) out=out & 0x7f; else out=out | 0x80; CLK=1; } return(out); } void quit() { CLK = 1; STB = 1; PART = 1; } void jishi() { TMOD |= 0x10; TMOD &= 0xdf; TH1=0xb8; TL1=0x00; TR1=1; EA=1; ET1 = 1; } void ql() { xianshi(7,0,LEVEL_11); xianshi(6,0,LEVEL_11); xianshi(4,0,LEVEL_11); xianshi(3,0,LEVEL_11); xianshi(1,0,LEVEL_11); xianshi(0,0,LEVEL_11); } void xianshi(uint8 x,uint8 led,uint8 level) { uint8 i; static uint8 cled[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}; for(i = 0 ;i < 8;i ++ ){ if((shuzu[led]>>i)&0x01) cled[i] |= (0x01<< x); else cled[i] &= ~(0x01<< x); } PART=1; CLK=1; STB=1; indate(MD_WRITE); STB = 1; indate(DIG0); for( i = 0 ; i<16; i+= 2){ indate(cled[i/2] & 0x0f); indate(cled[i/2] >> 4 & 0x0f); } STB=1; indate(level); STB=1; } void ClearAll() { unsigned int i; PART=1; CLK=1; STB=1; indate(MD_AUTO); STB=1; indate(DIG0); for(i=0;i<16;i++) indate ( 0 ); STB=1; indate(0x80); STB=1; } void KeyRead(uint16 *key) { unsigned char key1,key2; STB=1; indate(MD_READKEY); key1 = outdate(); key2 = outdate(); *key = key1 | (key2 << 8); STB=1; } void delay() { uint16 n; uint8 k; for(k=0;k<10;k++) { for(n=0;n<6000;n++) ; } } [page] void zhongduan()interrupt 3 { shizhong(); } void start() { static uint16 count=0; static uint16 scount=0; static uint8 a=0; static uint8 b=0; static uint8 c=0; static uint8 d=0; static uint8 x=0; static uint8 y=0; TH1=0xb8; TL1=0x00; count++; if(count==5) { count=0; scount++; x=scount/10%10; y=scount/100%10; xianshi(7,x,LEVEL_11); if(scount%600==0) { xianshi(6,0,LEVEL_11);scount=0;a++; } else xianshi(6,y,LEVEL_11); if(a>=10) { a=0;b++; } xianshi(4,a,LEVEL_11); if(b>=6) { b=0;c++; } xianshi(3,b,LEVEL_11); if(d<2){ if(c==10){ c=0;d++;} xianshi(1,c,LEVEL_11); xianshi(0,d,LEVEL_11);} else if(d>=2){if(d>2)d=0; if(c==4){ c=0;d=0;} xianshi(1,c,LEVEL_11); xianshi(0,d,LEVEL_11);} KeyRead(&key); if(key==0x0008)a++; KeyRead(&key); if(key==0x0080)b++; KeyRead(&key); if(key==0x0800)c++; KeyRead(&key); if(key==0x8000)d++; if(key==0x0004){scount=0; x=0;y=0;} }} main() { ql(); state(); while(1){};
Previous article:MCU 32-port water lamp program
Next article:The role of microcontroller header files
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- How to import pictures in AD19 version and run script software crash
- JD642 SDRAM bus matching pre-simulation and pcb download
- [STM32WB55 Review] 6# Use of STM32WB development board UART
- [New Year's Taste Competition] + New Year's Eve dinner + New Year's 7 days of fun, I wish you all a prosperous New Year, smooth sailing and a good start.
- Sell TI POS Kit Chip
- cc2530 zigbee-zha modification supports serial port 1 position 1 P0_4 P0_5
- EEWORLD University ---- Learn myRIO with me
- Classic MATLAB simulation model for parameter identification of three-phase asynchronous motor
- 900 yuan, looking to buy a DE1-SOC, no accessories are required [
- EEWORLD University Hall----Introduction to FPGA Peripheral Circuits (Intel Official Tutorial)