现在想用STC15W4K系列单片机的串口3和串口4通讯,串口2和串口1通讯没问题,但是串口3和串口4不能收发数据
这是串口3的程序 能给我说说是不是还有什么配置没有写出来或者没写对啊
#include "STC15.h"
#define uchar unsigned char
#define uint unsigned int
#define FOSC 11059200
#define BAUD 9600
#define S3RI 0x01
#define S3TI 0x02
#define TM (65536-(FOSC/4/BAUD))
uchar flag,num;
void INIT(void)
{
//TMOD=0x10;
P_SW2&=0x00;
S3CON=0x10;
T2L=TM;
T2H=TM>>8;
AUXR=0x14;
IE2=0x08;
EA=1;
}
void main(void)
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
P6M0 = 0x00;
P6M1 = 0x00;
P7M0 = 0x00;
P7M1 = 0x00;
INIT();
while(1)
{
if(flag==1)
{
flag=0;
IE2=0x00;
S3BUF=num;
while((S3CON&S3TI)==0);
S3CON&=~S3TI;
IE2=0x08;
}
}
}
void UART() interrupt 14
{
if((S3CON & S3RI) != 0x00)
S3CON&=~S3RI;
num=S3BUF;
flag=1;
} |