The 52 chip has one more timer than the 51. So I also read a lot of information on the Internet, many of which could not run. After making some modifications, I finally realized the simulation test on Keli and Proteus. The following is my code and designed circuit.
/*-----------------------------------------------------------------------------
* Experiment name: RS232 serial port test
* Experimental description: The microcontroller serial port receives data to control the light on and off
* Connection method:
* Note: The crystal used in this test is 11.0592
***********************************************************************************/
#include #include #define uchar unsigned char #define uint unsigned int uchar PuZh[36] = "hello world"; //--Define the IO used--// sbit LED=P2^0; //--Declare global functions--// void UsartConfiguration(); void Delay_1ms(uint i); /******************************************************************** * Name: Com_Int() * Function: Serial port interrupt subfunction * Input: None * Output: None ***************************************************************************/ void Com_IntIsr(void) interrupt 4 { uchar i; uchar receive_data; EA = 0; if(RI == 1) //When the hardware receives a data, RI will be set { RI = 0; receive_data = SBUF; //Received data if(receive_data == '1') { LED =0; //Lights up when receiving 1 } else { LED =1; //light off in other cases } } for(i=0; i<36; i++) { SBUF = PuZh[i]; //Put the data to be sent into the send register while(!TI); //Wait for sending data to complete TI=0; //Clear the send completion flag Delay_1ms(1); } EA = 1; } /*********************************************************************************** * Function name: main * Function: Main function * Input: None * Output: None ***********************************************************************************/ void main() { UsartConfiguration(); //Initialize the serial port while(1); } /*********************************************************************************** * Function name: UsartConfiguration() * Function: Set the serial port * Input: None * Output: None ***********************************************************************************/ void UseArtConfiguration() { T2MOD = 0x01; //Automatically reload T2CON = 0x30; //T2 is used as the sending and receiving clock TH2 = 0xFF; //9600 baud rate, 11.0592Mhz crystal TL2 = 0xDC; RCAP2H = 0xFF; RCAP2L = 0xDC; SCON = 0x50; //Serial port mode 1, 1 start bit, 1 stop bit, 8-bit data, variable baud rate PCON = 0X00; //Baud rate is not doubled TR2 = 1; //Start T2 ES = 1; //Open serial port interrupt EA = 1; // Enable general interrupt } /******************************************************************** * Name: Delay_1ms() * Function: Delay subroutine, delay time is 1ms * x * Input: x (number of millisecond delays) * Output: None ***************************************************************************/ void Delay_1ms(uint i) //1ms delay { uchar x,j; for(j=0;j for(x=0;x<=148;x++); } Since I didn't use my own computer to draw the picture, I can't post the picture, but if I have time, I will definitely post the picture. But I will also talk about the general idea of the design, which is a minimum microcontroller system RX terminal connected to the RX terminal of the compim, TX connected to the TX terminal of the compim, and then the LED is connected to the 0 terminal of the P2 port.
Previous article:89c51 single chip microcomputer 32 heart-shaped water lights
Next article:51 MCU timer TMOD and TCON, SCON
- 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
- 【GD32E503 Evaluation】 ADC Experiment (Continued)
- PDI1394L41/L40 in IEEE 1394 Audio Application
- AT89C series microcontroller decryption principle
- STM32 core Arduino board-ZeroKnow mini board with small size
- [Urgent recruitment] Shanghai AGV famous company urgently recruits a large number of technical development talents with high salary
- Programming examples to learn DSP timer and interrupt system
- TI Battery Tester Reference Design for High Current Applications
- [ESK32-360 Review] + TFT screen display function and expansion (1)
- [NXP Rapid IoT Review] Part 2: Detailed tutorial of online IDE - Open Rapid IoT to see the weather...
- Common problems with lithium battery protection boards