TM1620 is a diode driver chip produced by Tianwei Company, SOP20 package. The chip is shown in the figure below:
It can drive up to 6 8-bit digital tubes, as shown in the following figure:
The procedure is as follows:
/****************************************************** * * Name: STC51 drives TM1620 3-digit digital tube display * MCU: STC12C5608AD * Main frequency: 12Mhz (external 12MHz crystal oscillator) * Author: Ration * Date: December 5, 2013 (edited) * Copyright: Copyright belongs to "MCU Learning Network". Please keep integrity when disseminating. * * For more programs, please visit: http://www.rationmcu.com *************************************************/ #include "stc12c5608ad.h" #include#define uint unsigned int // Macro definition uint (0~65535) #define uchar unsigned char // #define uint32 unsigned long sbit STB =P3^2; // define chip select communication port sbit CLK =P3^3; // Define the clock communication port sbit DIO =P3^4; //Define data input/output communication port uchar bai_num,shi_num,ge_num; static uchar code LED_tab[11]={ //Define the digital code table of digital tube 0~9 0x3f, //0B00111111, //0 0x30, //0B00000110, //1 0x6d, //0B01011011, //2 0x79, //0B01001111, //3 0x33, //0B01100110, //4 0x5b, //0B01101101, //5 0x5f, //0B01111101, //6 0x70, //0B00000111, //7 0x7f, //0B01111111, //8 0x7B, //0B01101111, //9 0x4f, //E }; void delay_ms(uchar cyc) { //When = 1, delay 1ms uchar ii,jj; for(jj=1;jj<=cyc;jj++) { for(ii=0;ii<200;ii++) { _nop_(); } } } void TM1620_Write(uchar wr_data) { uchar i; for(i=0;i<8;i++) { CLK = 0; if(wr_data&0x01)DIO = 1; else DIO = 0; CLK = 1; wr_data>>=1; } } void Write_COM(unsigned char cmd) //Send command word { STB = 0; TM1620_Write(cmd); STB = 1; } void init_TM1620(void) { Write_COM(0x44); // 01000000 ready to write data to the display register, normal mode, automatic address increase STB=0; TM1620_Write(0xc0); // 11000000 Set the display address to start from 0 TM1620_Write(0x00); // All displays are off STB=1; STB=0; TM1620_Write(0xc2); TM1620_Write(0x00); STB=1; STB=0; TM1620_Write(0xc4); TM1620_Write(0x00); STB=1; Write_COM(0x8f); // Brightest 10001111 Set extinction pulse 14/16 Display on } void led_show() { // Write_COM(0x44); // 01000000 ready to write data to the display register, normal mode, automatic address increase STB=0; TM1620_Write(0xc0); // 11000000 Set the display address to start from 0 TM1620_Write(LED_tab[bai_num]); // All displays are off STB=1; STB=0; TM1620_Write(0xc2); // 11000000 Set the display address to start from 0 TM1620_Write(LED_tab[shi_num]); // All displays are off STB=1; STB=0; TM1620_Write(0xc4); // 11000000 Set the display address to start from 0 TM1620_Write(LED_tab[ge_num]); // All displays are off STB=1; } void main() { CLK = 1; // Pull up the TM1620 communication clock pin STB = 1; // Pull up the TM1620 communication chip select pin DIO = 1; // Pull up the TM1620 communication data pin init_TM1620(); // Initialize the LED control chip bai_num=0; shi_num=0; ge_num=0; led_show(); while(1) { ; } }
Please obtain the complete Keil project file as follows!
Previous article:Solution to 51 MCU PWM duty cycle less than 0
Next article:stc51 MCU pwm program stc12c5608ad
- Popular Resources
- Popular amplifiers
- Learn ARM development(14)
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Discover Schottky diodes in daily life
- [RVB2601 Creative Application Development] Graphical display and simple recognition of sound (work submission)
- TCP protocol requires restarting the circuit board for each connection
- The world is moving towards 5G. Do you think it’s time to switch to a 5G phone?
- [Good book download] 300 examples of classic intelligent circuits!
- Allegro Issues
- 【National Technology N32G430】1: Preliminary Study
- How to layout the PCB of photovoltaic power supply?
- A Beginner's Guide to PCB Design
- Ultrasonic utility knife (cutting knife) 2999RMB ???