1 Introduction
Send data to the microcontroller through the serial port, and then the data + 1 is returned to the serial port
2. Function Implementation
#include #define uchar unsigned char #define uint unsigned int sbit beep = P2^3; //Buzzer interface uchar num; //Send temporary variable void delay(uint z) { uint x,y; for(x = z; x > 0; x--) for(y = 114; y > 0 ; y--); } void UART_init() { TMOD = 0x20; //T1 working mode 2 8-bit automatic reload TH1 = 0xfd; TL1 = 0xfd; //bit rate 9600 TR1 = 1; //Start T1 timer SM0 = 0; SM1 = 1; //Serial port working mode 1 10-bit asynchronous REN = 1; //Serial port allows receiving EA = 1; // Enable general interrupt ES = 1; //Serial port interrupt is turned on } void main() { UART_init(); //Serial port initialization while(1); } void UART() interrupt 4 //Serial port interrupt { if(RI) //Check whether the reception is completed. When the hardware receives a data, RI is high. { num = SBUF; //num takes out the value of the receive buffer beep = 0; delay(100); beep = 1; //The buzzer emits a beeping sound num++; //add 1 to the received data and send it RI = 0; SBUF = num; //Return data to the buffer while(!TI); TI = 0; } }
Previous article:The use of 89C52 single chip microcomputer timer interrupt
Next article:51 MCU Basics DS18B20 Temperature Sensor
Recommended ReadingLatest update time:2024-11-22 22:27
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- MM32F031 Development Board Review 11: Simulating Lighting of 0.96-inch OLED
- Research on high power DC/DC converter based on UC3846
- MicroPython - Python for microcontrollers
- Wireless transmission power quality monitoring system circuit
- Technical safety and reliability issues
- New changes are brewing amid ups and downs in the global semiconductor industry
- 2020 Share my thoughts on Qian'an, a national healthy and civilized county-level city
- MOS tube drain ringing
- Learn the data types that you must master in Siemens S7-200 series PLC
- [Pre-register to win a multimeter and JD card] Prize live broadcast | ADI's latest switches and multiplexers, technical parameters, design...