C8051F020编程UART串口收发数据
我编了一个 老是编译不过去 求高手改正
我用的是UART0端口 方式2
程序如下
//>>UART0串口编程--向PC发送和接受字符串<<
//
//--------------------------------------------------------------------------
#include
#include
#define uchar unsigned char
#define uint unsigned int
//----------------------------------------------------------------------
//参数设置区
//----------------------------------------------------------------------
#define BAUDRATE 138240 //波特率bps
#define SYSCLK 22118400 //外部晶振,修改也要修改OSCXCN
#define T4VAL (65536-SYSCLK/BAUDRATE/32) //定时器4初值
uchar idata reaeice_flag=0;
extern uchar idata timer_sec;
uchar idata send_buffer[10]; //数据缓冲区
uchar idata receive_buffer[20];//接收数据队列
uchar time = 0; //软件计时次数
uchar period = 25; //定时间隔 20ms * 25 =500ms