MCU serial port program template

Publisher:老卫Latest update time:2015-05-08 Source: 51heiKeywords:MCU  Template Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include

void main()

SCON = 0x50; //Mode 1 (SM0 SM1:0 1) serial port 10-bit universal asynchronous interface. Sending or receiving a frame of data information is 10 bits, including 1 start bit "0", 8 data bits, and 1 stop bit "1".
 
TMOD=0X20; //Set the timer working mode 2 and load the value to start
TH1=0XFD;
TL1=0XFD;
TR1=1;

EA=1; //Turn on the general interrupt
ES=1; //Turn on the serial port interrupt
//while(1);

}
void write() interrupt 4

 if(RI==1)// Sending end flag
 {
 RI=0; //Reset to 0 for next sending
 P0=SBUF; //Send to P0 port
 }
 else
 TI=1;
}

Keywords:MCU  Template Reference address:MCU serial port program template

Previous article:Comprehensive use of C language for, while, if-else, return statements
Next article:Serial communication between microcontroller and host computer

Recommended ReadingLatest update time:2024-11-16 03:30

atmega48 microcontroller features atmega48 low power design
This article mainly introduces the characteristics of atmega48 microcontroller, puts forward the general method of its low power design, and takes the design of timing control system as an example to specifically explain the low power design scheme of atmega48. With the development of microelectronics and computer t
[Microcontroller]
atmega48 microcontroller features atmega48 low power design
The process of MCU processing analog quantity
MCU can only process digital quantities, so digital input----- MCU-------- digital output MCU cannot process analog quantity directly, so analog quantity input---- analog signal processing----- Analog-to-digital converter--- MCU------ digital-to-analog converter---- analog signal processing--- analog output Theref
[Microcontroller]
How to clearly distinguish between MCU and ARM?
  1. The concept of MCU and ARM   A single-chip microcomputer is an integrated circuit chip that uses very large-scale integrated circuit technology to integrate a central processing unit CPU with data processing capabilities, random access memory RAM, read-only memory ROM, multiple I/O ports and interrupt systems,
[Microcontroller]
C51 MCU timer T2 countdown program + circuit diagram
  Circuit diagram of digital tube part    51 single chip microcomputer program: #include reg52.h #define UCHAR unsigned char #define UINT unsigned int //sbit KEY=P3^2; UCHAR table = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; UINT context; UCHAR timer;  
[Microcontroller]
C51 MCU timer T2 countdown program + circuit diagram
Realize the process of USB_Flash_BootLoader HID to flash the AVR microcontroller chip program
In the early stage of making USBASP, I learned the BootLoader principle of AVR microcontroller chip, found a lot of information about USB-HID and BootLoader, and made a simple atmega8(16) board that can flash the program. Now I will share what I have learned with you. 1. About BootLoader         BootLoader means that
[Microcontroller]
Realize the process of USB_Flash_BootLoader HID to flash the AVR microcontroller chip program
MCU pin flip test
The IO port rate of STM32 can reach 50MHz, but when the IO port is used as a read/write signal to read and write data, the flip rate is not that fast. When using STM32 to read digital camera data and write it into TFT, the data transmission rate is involved, and the IO port needs to be flipped quickly. So, I did thi
[Microcontroller]
Schematic diagram of thermometer circuit based on single chip microcomputer
The figure below is the circuit schematic of a thermometer based on a single-chip microcomputer and a temperature sensor DS18B20
[Analog Electronics]
Schematic diagram of thermometer circuit based on single chip microcomputer
MCS-51 microcontroller assembly language: What are the logical operation instructions?
Simple logic operation instructions CLR A; A←  " 0 " CPL A; A←A SWAP A; A0~3 A4~7   Rotate Accumulator Left RL A   Rotate Accumulator Left through Carry flag   RLC A   Rotate Accumulator Right R R   Rotate A Right with C RRC A   Logic an
[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

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号