CT107D Blue Bridge Cup Serial Port Example (3)

Publisher:心若澄明Latest update time:2019-09-26 Source: eefocusKeywords:CT107D Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Today I will tell you about the serial communication of this board.


Here we don't need to look at the board, as long as we know how to use the serial port of the 51 chip. Let's go directly to the code.


#include "reg52.h"

str AUXR=0x8e; 51 special registers are not detailed

void init_uart()

{

SCON=0x50; Allow serial port interrupt mode 1, i.e. 8-bit asynchronous communication

AUXR=0x40; 1T

TMOD|=0x20; Timer mode 3 auto-reload

TH1=256-(11059200/9600/32); baud rate 9600

ES=1; Enable serial port interrupt  

TR1=1; Timer 1

EA=1; Total interrupt

}

void main()

{

unsigned char buf;

init_uart(); 

if(RI) Receive flag

{

RI=0; software clear

buf=SBUF; Get a byte

}

SBUF=buf; send data

while(!TI); Determine whether to send

}


Keywords:CT107D Reference address:CT107D Blue Bridge Cup Serial Port Example (3)

Previous article:CT107D Blue Bridge Cup dynamic digital tube example (4)
Next article:CT107D Bluebridge Buzzer and Relay (2)

Latest Microcontroller Articles
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号