PC与单片机双向通讯智能温控程序 #include <AT89X51.H> #include <intrins.h> #define Key_UP P1_0 #define Key_DOWN P1_1 #define Key_SET P1_2 #define RelayOutPort P2_0 #define LEDPort P0 #define DELPort P2_1 #define LEDTwoC P3_6 #define LEDThreeC P3_7 #define TMPort P2_7 #define INBUF_LEN 5 //数据长度 unsigned char inbuf1[INBUF_LEN]={ 0 , 0 , 0 , 0 , 0 } //发送缓冲区 unsigned char inbuf2[50] //接收缓冲区 unsigned char count3 void init_serialcomm( void ) { SCON = 0x50 //SCON: serail mode 1, 8-bit UART, enable ucvr TMOD |= 0x20 //TMOD: timer 1, mode 2, 8-bit reload PCON |= 0x80 //SMOD=1 TH1 = 0xFA //Baud:4800 fosc=11.0592MHz IE |= 0x90 //Enable Serial Interrupt TR1 = 1 // timer 1 run } //向串口发送一个字符 void send_char_com( unsigned char ch) { SBUF=ch while (TI== 0 ) TI= 0