#include <STC89C5xRC.H>
unsigned char code DIG_CODE[10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};
char buf;
void delay()//provide delay
{
int i, j;
for(i = 0; i < 15; i ++)
for(j = 0; j < 15; j ++)
;
}
void disp_digit(char d)
{
//Display the single digit
P0 = DIG_CODE[d % 10];
P2 = 0; // 0000 0000 -> (P24, P23, P22) = (0, 0, 0) -> The first digit from the right is lit
delay();
//Display ten digits
P0 = DIG_CODE[d / 10];
P2 = 1 << 2; // 0000 0100 -> (P24, P23, P22) = (0, 0, 1) -> The second digit from the right is lit
delay();
}
void UART_INT() interrupt 4 //UART中断
{
if(RI == 1)
{
RI = 0;
buf = SBUF;
}
}
int main()
{
TMOD = 0x21; //Set the working mode of timer1
SCON = 0x50; //Set serial communication format
TH1 = 0xE6; //Set the initial value of timer1
TL1 = 0xE6;
IE = 0x90; // Main switch closed (EA) + serial port interrupt switch closed (ES)
TR1 = 1; //Start timer1
while(1)
{
disp_digit(buf);
}
return 0;
}
Previous article:8051 MCU implements a single countdown timer with modifiable initial value (and command to start and stop)
Next article:8051 MCU realizes serial communication in polling mode (51 receives data and sends it back to PC)
Recommended ReadingLatest update time:2024-11-15 11:30
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- STC32G Series MCU Technical Reference Manual
- 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)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- Chinese mobile phones continue to sell well in India, Vivo surpasses Samsung to become the second largest brand
- A huge reward! Looking for someone who can crack the RSA2048 and factory protocol in the ECU!
- Family Pet Health Maintenance System
- HF Antenna Analyzer(3MHz to 30MHz)
- 1. Previous Power Supply Competition Topics
- The "Soul" of the Microcontroller - The Use of Data Memory
- Detailed Explanation of I2C Bus Protocol
- What is the difference between package 0603 and R0603 (or 0603R)?
- [Yatli AT32F421 Review] Doubts from EXTI disconnection
- List of instruments, equipment and main components for the 2019 National Undergraduate Electronic Design Competition