都快一个月了,还是一点反应都没有,用串口调试助手发送和接收都为空其中T0用做8251对89C52的发送接收中断信号 #define _TEST_C_ #include "reg52.h" #include "stdlib.h" #include "absacc.h" #include "intrins.h" #include "test.h"
#define uchar unsigned char #define uint unsigned int #define COM8251 XBYTE[0x8601] #define DAT8251 XBYTE[0x8600] uchar data_temp[10]={0xAA,10,22,32,0,0}; uchar i,s; void initmcu(void);
void main(void) { EA = 1; initmcu(); COM8251 = 0x00; COM8251 = 0x00; COM8251 = 0x00; COM8251 = 0x4e; COM8251 = 0x37; } void initmcu(void) { TMOD = 0x06; //9600波特11.0592MHz,方式2 TL0 = 0XFF; TH0 = 0XFF; TCON = 0x01; IP = 0x02; ET0 = 1; }
void Trans8251() interrupt 1 using 2 { for(;;) { for(i=0;i<4;i++) { do { s = COM8251; }while((s&0x01)==0); DAT8251 = data_temp; } for(i=0;i<4;i++) { do { s = COM8251; }while((s&0x02) == 1); } data_temp = DAT8251; } }
|