org 0000H
AJMP START
ORG 30H
START:
mov SP,#5fh ;
mov TMOD,#20h ;T1: work mode 2
mov PCON,#80h ;SMOD=1
mov TH1,#0FDH ;Initialize baud rate (see table)
mov SCON,#50h ;Standard UART settings
MOV R0,#0AAH ;Prepare to send data
SETB REN ;Enable receiving
SETB TR1 ;T1 starts working
WAIT:
MOV A,R0
CPL A
MOV R0,A
MOV SBUF,A
LCALL DELAY
JBC TI,WAIT1 ;If TI is 1, clear TI and go to WAIT1
AJMP WAIT
WAIT1: JBC RI,READ ;If RI is 1, clear RI and go to READ
AJMP WAIT1
READ:
MOV A,SBUF ;Send the obtained number to port P1
MOV P1,A
LJMP WAIT
DELAY: ;Delay subroutine
MOV R7,#0ffH
DJNZ R7,$
RET
END
Compile the program, write it into the chip, insert it into the experimental board, and use the through-read cable to connect the experimental board to the serial port of the host to conduct the experiment. The function of the above program is very simple, which is to send 55H and AAH to the host in turn at regular intervals, and send the number sent by the host to port P1. You can use the serial port wizard on the PC to do experiments. The serial port wizard is available for download on my homepage. After running the serial port wizard, press the "Set Parameters" button on the main interface to enter the "Set Parameters" dialog box and set the parameters according to the following parameters. Note that my machine uses serial port 2. If you are not using serial port 2, please change the serial port settings yourself.
After setting, press OK to return to the main interface. Note that there is a drop-down list on the right, and "According to Hexadecimal" should be selected. Then press "Start Sending" and "Start Receiving". According to this setting, two lights should be on and six lights should be off on the experimental board. You can change the sending characters in the setting parameters such as 55, 00, FF, etc., observe the lights on and off, and analyze the reasons. You can also change the "According to Hexadecimal" in the drop-down list on the main interface to "According to Decimal" or "According to ASCII Characters" to observe the phenomenon and analyze it carefully. This is also very helpful for everyone to understand hexadecimal, decimal, and ASCII characters. The program itself is very simple and has comments, so I won't explain it in detail here.
Previous article:Serial port asynchronous communication microcontroller programming example (implemented by interrupt method)
Next article:51 MCU serial port communication program design example
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Does the boost topology circuit limit the duty cycle?
- Op amp differential amplification problem
- FAQ_How to fill in the BQB certification application form
- [2022 Digi-Key Innovation Design Competition] Material Unboxing Raspberry Pi 400
- HC6800 EM3 V2.0 CD-ROM
- Share the temperature and humidity monitoring of LoRa communication technology
- [TI star product limited time purchase] + AWR6843 purchase experience and unboxing
- EEWORLD University ---- VLSI Testing
- 【STEVAL-MKI109V3+LSM6DSOX】Build a test environment from scratch
- Python3 string substring search, replacement, deletion, splitting, connection related methods