c8051f350串口通信
发布时间:2021-06-07
发布时间:2021-06-07
串口通信
//使用F350,串口为P0.4,P0.5;
kkk//-----------------------------------------------------------------------------
// 所包含的头文件
//------------------------------------------------------------------------
#include <c8051f350.h>
#include <stdio.h>
//-----------------------------------------------------------------------------a
// 常量定义
//-----------------------------------------------------------------------------
#define SYSCLK 24500000 // 系统工作频率
#define BAUDRATE 9600 // 串口工作波特率
//-----------------------------------------------------------------------------
// F35x’定时器2的16位SFR
//-----------------------------------------------------------------------------
// sfr16 TMR2RL = 0xca;
// sfr16 TMR2 = 0xcc;
//-----------------------------------------------------------------------------
// 功能函数
//-----------------------------------------------------------------------------
void SYSCLK_Init (void);
void PORT_Init (void);
void UART0_Init (void);
void UART0_ISR (void);
bit ReceiveBit;
//unsigned char temp;
#define UART_BUFFERSIZE 64
unsigned char UART_Buffer[UART_BUFFERSIZE];
unsigned char UART_Buffer_Size = 0;
unsigned char UART_Input_First = 0;
unsigned char UART_Output_First = 0;
unsigned char TX_Ready =1;
static char Byte;
/*延时程序*/
void delay(unsigned int m)