各位大神 帮忙求解下 关于stc12c5a60s2串口2发送问题
时间:10-02
整理:3721RD
点击:
void Send(BYTE Ch)
{
// IE2 = 0X00;
S2BUF = Ch;
while (!(S2CON&0X02));
S2CON&=~0X02;
}
//串口字符串发送
void SendString(signed char *s)
{
while (*s)
{
Send(*s);
s++;
}
}
void McuInit()
{
//IO口配置为标准IO
P4M0 &= ~0x01;
P4M1 &= ~0x01;
P3M0 &= ~0xc0;
P3M1 &= ~0xc0;
//P3M1 |= 0x10;
P2M0 = 0x00;
P2M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P0M0 = 0x00;
P0M1 = 0x00;
//总中断关闭
EA = 0;
//BRT,串口波特率设置,9600
PCON = 0x00;
BRT = 0xfd;
AUXR = 0x11;
SCON = 0x50;
ES = 1;
AUXR1=AUXR1|0X10;
//总中断开启
EA = 1;
return;
}
void Mcu_timer0()
{
//计数器0,未启用
TMOD |= 0X01;
// ET0 = 1;
TL0 = 0X175;
TH0 = 0X60;
TR0 = 1;
ET0=1;
EA =1;
}
我主要想把p0口数据通过串口2发送给上位机, 可是一直调试不了,程序不报错 ,可是就是没数据出来(com2切换到p4口上), 麻烦大家帮我看下 这部分程序是不是有点问题
{
// IE2 = 0X00;
S2BUF = Ch;
while (!(S2CON&0X02));
S2CON&=~0X02;
}
//串口字符串发送
void SendString(signed char *s)
{
while (*s)
{
Send(*s);
s++;
}
}
void McuInit()
{
//IO口配置为标准IO
P4M0 &= ~0x01;
P4M1 &= ~0x01;
P3M0 &= ~0xc0;
P3M1 &= ~0xc0;
//P3M1 |= 0x10;
P2M0 = 0x00;
P2M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P0M0 = 0x00;
P0M1 = 0x00;
//总中断关闭
EA = 0;
//BRT,串口波特率设置,9600
PCON = 0x00;
BRT = 0xfd;
AUXR = 0x11;
SCON = 0x50;
ES = 1;
AUXR1=AUXR1|0X10;
//总中断开启
EA = 1;
return;
}
void Mcu_timer0()
{
//计数器0,未启用
TMOD |= 0X01;
// ET0 = 1;
TL0 = 0X175;
TH0 = 0X60;
TR0 = 1;
ET0=1;
EA =1;
}
我主要想把p0口数据通过串口2发送给上位机, 可是一直调试不了,程序不报错 ,可是就是没数据出来(com2切换到p4口上), 麻烦大家帮我看下 这部分程序是不是有点问题
你的主函数-。-