有方M590E GSM模块,用STC12C5A60S2 可以串口通信, 一切正常...用STC15W204S与模块就不行,模块与串口助手可以通信,STC15W204S与串口助手也可以通信,波特率都设置成38400,何解?
#include <stc15w204s.h>
#include <stdio.h>
#include <string.h>
void UartInit(void) //38400bps@11.0592MHz
{
SCON = 0x50; //8位数据,可变波特率
AUXR |= 0x01; //串口1选择定时器2为波特率发生器
AUXR |= 0x04; //定时器2时钟为Fosc,即1T
T2L = 0xB8; //设定定时初值
T2H = 0xFF; //设定定时初值
AUXR |= 0x10; //启动定时器2
}
void delay(unsigned int time)
{
unsigned int i;
for(;time>0;time--)
{ i=1500;
while(i--);
}
}
void main(void)
{
UartInit();
TI=1;
printf("ATD1****16235;\n");
delay(15000);
printf("ATH\n");
delay(10000);
printf("ATD>3;\n"); //前面的电话号码在卡的电话薄第3位
delay(15000);
printf("ATH\n");
while(1);
}
|