由于8位单片机一般只有一个串行接口,往往不够用,只能自己写一个模拟串口的程序,下面这个程序是自己早先写的,放上来,对别人也许有点用,注意接收端同时接到P3.2(INT0)
#include <at89X52.h>
#define DOUBLE_BAUDRATE
#define DATA_CORRUPT 0x80
#define BUFFER_OVERFLOW 0x81
#define F_OSC 11059200
#define BAUDRATE 9600 //115200//57600//19200//9600
#define BAUDRATE_CONST (256 - F_OSC/12/BAUDRATE)
#define HALF_BAUDRATE (256 - F_OSC/12/BAUDRATE/2)
#define DELAY_TIME 50;//ms
#define DELAY_CONST (DELAY_TIME/1000 * F_OSC)/12
#define DISABLE_RECEIVE() EX0 = 0;
#define ENABLE_RECEIVE() EX0 = 1;
#define RXD P1_2
#define TXD P1_3
char idata buffer[32] ;
unsigned char bdata DataBuf;
sbit DataBuf_0 = DataBuf ^ 0;
sbit DataBuf_1 = DataBuf ^ 1;
sbit DataBuf_2 = DataBuf ^ 2;
sbit DataBu
#include <at89X52.h>
#define DOUBLE_BAUDRATE
#define DATA_CORRUPT 0x80
#define BUFFER_OVERFLOW 0x81
#define F_OSC 11059200
#define BAUDRATE 9600 //115200//57600//19200//9600
#define BAUDRATE_CONST (256 - F_OSC/12/BAUDRATE)
#define HALF_BAUDRATE (256 - F_OSC/12/BAUDRATE/2)
#define DELAY_TIME 50;//ms
#define DELAY_CONST (DELAY_TIME/1000 * F_OSC)/12
#define DISABLE_RECEIVE() EX0 = 0;
#define ENABLE_RECEIVE() EX0 = 1;
#define RXD P1_2
#define TXD P1_3
char idata buffer[32] ;
unsigned char bdata DataBuf;
sbit DataBuf_0 = DataBuf ^ 0;
sbit DataBuf_1 = DataBuf ^ 1;
sbit DataBuf_2 = DataBuf ^ 2;
sbit DataBu