现在想用STC15的串口4进行触摸屏的通讯,但是在实验时串口1和2通讯完全没问题,但是到了串口4就不能通讯了,试了串口3也不行,不知道程序都是按照手册上的寄存器设置写的,不知道是不是串口3和4还有什么特殊的设置?串口3和4都是用的默认接口,串口3是P0,0 P0,1 串口4是P0,2 P0,3
#include "STC15.h"
#define uchar unsigned char
#define uint unsigned int
#define FOSC 11059200
#define BAUD 9600
#define S3RI 0x01
#define S3
ti 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 17
{
if((S3CON & S3RI) != 0x00)
S3CON&=~S3RI;
num=S3BUF;
flag=1;
}
一周热门 更多>