main.c
#include #include "intrins.h" #include "Max7219.h" uchar code laji[][8]={ {0x18,0x24,0x42,0x42,0x7E,0x42,0x42,0x42},//A {0x7C,0x42,0x42,0x7C,0x42,0x42,0x42,0x7C},//B {0x3C,0x42,0x40,0x40,0x40,0x40,0x42,0x7C},//C {0x7C,0x42,0x42,0x42,0x42,0x42,0x42,0x7C},//D }; /*n milliseconds delay program*/ /*void Delay_xms(uint x) { uint i,j; for(i=0;i }*/ void main() { flying i,j; //Delay_xms(50); MAX7219Init(); while(1) { for(j=0;j<8;j++) { for(i=0;i Max7219WR(j+1,laji[i][j]); } CS=1; _nop_(); CS=0; //Delay_xms(100); } } } Max7219.h #ifndef _Max7219_H_ #define _Max7219_H_ #define uchar unsigned char #define uint unsigned int #define number 4 //Number of dot matrix cascades #define lum 5 //Brightness level, 0-F, 16 levels in total //Define Max7219 port sbit CLK = P2^2; //Clock Max7219_pin sbit CS = P2^1; // latch sbit DIN = P2^0; //data //Write address and data to MAX7219 void Max7219WR(fly addr,fly dat) { fly n=8; CLK=0; CS=0; //CS=0 is valid, CS=1 is latched /*Send data high bit first*/ while(n--) { DIN = addr & 0x80; CLK=1; addr <<= 1; CLK=0; } n=8; /*Send data high bit first*/ while(n--) { DIN = dat & 0x80; CLK=1; dat <<= 1; CLK=0; } } void MAX7219Init() { flying i,j; for(i=0;i<5;i++) // { for(j=number;j>0;j--) switch(i) { case 0:Max7219WR(0x09, 0x00); break; //Decoding mode: BCD code is not decoded case 1:Max7219WR(0x0A, lum); break; //Brightness 0-15, 16 levels in total case 2:Max7219WR(0x0B, 0x07); break; //Scan limit; 8-bit display case 3:Max7219WR(0x0C, 0x01); break; //Power-down mode: 0, normal mode: 1 case 4:Max7219WR(0x0F, 0x00); break; //Display test: 1; Test ends, normal display: 0 } CS=1; _nop_(); CS=0; //Give a latch pulse every four writes } } #endif
Previous article:Single chip electronic password lock program design (assembly language) display *
Next article:Campus work and rest control system based on 51 single chip microcomputer assembly
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- 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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- ECG monitor solution based on DSP system platform
- Finding the missing pieces of the TI power puzzle
- A novice asks about AD copper plating, thank you
- Compact W600 development board
- F28335 Memory Map
- Imported project compilation fails
- [Project Outsourcing] Optimize the Raspberry Pi boot time to 5-8 seconds
- How to buy ti boards from Chinese dealers?
- UWB Positioning Technology
- TLP3547 Evaluation Board Evaluation Report (Completed)