MCU-Serial port communication with PC

Publisher:Huixin8888Latest update time:2022-09-13 Source: csdnKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;First, send characters to the MCU through the serial port debugging tool, i.e., the PC. After the MCU receives the data, it sends it to the PC. 

; Observe the transmission result again through the serial port debugging tool, that is, the transmission and reception from PC to MCU is realized

;Due to local simulation, a virtual serial port needs to be installed. The PC uses COM1 port, and the MCU's COMPIM is set to COM2. The baud rate is 9600

        org 0000h

        ajmp main

        org 0023h

        ajmp aa

        org 0030h

main: mov scon, #50h ; Set the MCU serial port mode 1 to receive

        mov tmod,#20h ;Timer T1 works in timing mode 2

        mov pcon,#00h ;Serial port baud rate SMOD=0,Fosc=11.0592M

        mov th1,#0fdh ; Timer T1 initial value = FDH, generating 9600 baud rate

        mov tl1,#0fdh

        setbea

        set b es  

        setb tr1

        CLR F0; F0 = 0 receive

        mov a,sbuf ; start serial port to receive data

        sjmp $

aa: JB F0,TRS

        SETB F0

        clr ri ; Clear the RI flag after receiving a data

        MOV SCON,#40H ; Set the MCU serial port mode 1 to send

        MOV SBUF,A ; Start the serial port to send data

        RETI                

TRS: CLR TI ; Clear the TI flag after sending a data

        CLR F0

        MOV SCON,#50H ; Set the MCU serial port mode 1 to receive

        mov A,sbuf ; start serial port to receive data   

        RETI    

        end

Write the picture description here

Write the picture description here


Keywords:MCU Reference address:MCU-Serial port communication with PC

Previous article:51 single chip microcomputer output square wave problem
Next article:Microcontroller Experiment - A/D and D/A Conversion

Recommended ReadingLatest update time:2024-11-16 07:45

Design of power fault control system for AT89C5l microcontroller
1 Introduction There have been many studies on power grid short circuit and line fault detection and protection. The electrical short-circuit, overload, and overvoltage protectors on the market have a single function. Easily damaged, useless prompt function, not user-friendly enough. But with the continuous improvemen
[Microcontroller]
Design of power fault control system for AT89C5l microcontroller
80C51 MCU-LED running water light effect (assembly version)
This article will introduce a marquee experiment based on 8051 microcontroller, and realize the LED running light effect by writing assembly code. This experiment will use the P2 port of 8051 microcontroller to control 8 LED lights to realize the running light effect. Experimental preparation
[Microcontroller]
Analysis of the calculation method of C51 microcontroller delay time
Different types of variables can be used in C programs for delay design. After experimental testing, using the unsignedchar type has more optimized code than unsignedint. When using it, unsignedchar should be used as a delay variable. Take a microcontroller with a crystal oscillator of 12MHz as an example. If the crys
[Microcontroller]
How to use Keil3 to develop 51 microcontroller program
1. Double-click the icon to open the Keil software 2. Click - on the menu bar 3. Save the new project to a folder 4. Choose a CPU chip, here STC89C52RC corresponds to Philips' P89V51RD2 5. Prompt whether to copy the startup code of 8051 to the folder. Select "No" here. 6. After completion, you can see Sou
[Microcontroller]
How to use Keil3 to develop 51 microcontroller program
Green Hills µ-velOSity RTOS and ST's Stellar SR6 MCU work closely together
ST Authorized Partner Green Hills Software has designed an integrated hardware-software solution that provides significant advantages to embedded systems developers. The innovative platform combines the Green Hills Software µ-velOSity real-time operating system (RTOS) with the advanced capabilities of ST'
[Embedded]
Green Hills µ-velOSity RTOS and ST's Stellar SR6 MCU work closely together
Microcontroller Introduction Tutorial Lesson 22 - Serial Port Application Programming Example
1. Serial port mode 0 application programming 8051 microcontroller serial port mode 0 is the shift register mode. By connecting an external shift register with serial input and parallel output, a parallel port can be expanded. Example: Use the 8051 serial port to externally connect to the CD4094 to expand the 8-bit p
[Microcontroller]
Microcontroller Introduction Tutorial Lesson 22 - Serial Port Application Programming Example
Can a microcontroller run an operating system?
Let’s get straight to the answer first: Yes! However, the operating system is not strictly necessary . The operating system takes up more resources of the microcontroller, such as FLASH and RAM, which indirectly increases the hardware cost. Even if the cost increases by 1 cent, for high-volume products, every minute
[Microcontroller]
Decryption principle of AT89C51 microcontroller
  MCU decryption is simply to erase the encryption lock bit in the MCU. Due to the unreasonable design of the erase operation timing of the AT89C series microcontroller. Makes it possible to erase the cryptographic lock bits first before erasing the on-chip program.   The timing sequence of the erase operation of th
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号