写了如下一段代码,烧到板子里面后,用串口模拟工作测试,无法输出值
#include<math.h></math.h>
#include<string.h></string.h>
#include <regxag49.h></regxag49.h>
void SerialSendByte(char dat);
void SerialSendStr(char *str);
void SerialInterrupt(void);
void SerialSendInt(int);
void Modem_Init(void);
void SendECG();
void Uart_init();
signed int ECG[]={0,0,0,0,2,4,6,8,9,11,13,12,11,9,7,5,3,2,0,0,0,0,
-7,-15,-2,21,44,66,70,55,24,-4,15,-20,-16,-7,-2,0,0,0,0,0,0,
1,1,1,2,3,4,4,5,5,5,4,3,3,2,1,0,0,0,0,0};
int m=0;
void Delay();
void Uart_init(void) //uart initialization
{
TMOD |= 0x20; /* timer1, mode 2, 8 bit reload */
S0CON = 0x50; /* serial mode 1, 8 bit uart, enable receive */
//PCON = 0x80; /* SMOD = 1, double baud */
TH1 = 0xFA; /* baud = 9600, fosc = 11.0592MHZ */
TL1 = 0xFA;
RI0 = 0; /* clear receive flag */
TI0 = 0; /* clear send flag */
TR1 = 1; /* start timer1 */
IE0 = 1; /* enable serial interrupt */
EA = 1; /* enable all interrupt */
}
void SerialSendByte(char dat)
{
S0BUF = dat;
while(TI0 == 0);
TI0 = 0;
}
void SerialSendStr(char *str)
{
while(*str != '\0')
{
SerialSendByte(*str);
str++;
}
}
void Modem_Init()
{
//MODEM INIT
SerialSendByte(0x0D);//0x0D -- ASCII code of 'enter'
Delay();
SerialSendStr("AT");
Delay();
SerialSendByte(0x0D);
Delay();
SerialSendByte(0x0A);
Delay();
SerialSendStr("AT+IPR=9600");//baud rate
Delay();
SerialSendByte(0x0D);
Delay();
SerialSendByte(0x0A);
Delay();
SerialSendStr("AT+CMGF=1");// text mode
Delay();
SerialSendByte(0x0D);
Delay();
SerialSendByte(0x0A);
Delay();
SerialSendStr("AT+CNMI=1,1");//Noticifacation
Delay();
SerialSendByte(0x0D);
Delay();
SerialSendByte(0x0A);
Delay();
SerialSendStr("AT+CMGS=+447546338662");//mobile number
Delay();
SerialSendByte(0x0D);
Delay();
SerialSendByte(0x0A);
Delay();
Delay();
Delay();
}
void SerialSendInt(int number) // Sendiniteger; int->ASCII
{
const char dec[]="0123456789";
unsigned long int div=10;
if( number < 0) //if number is negative send '-' sign.
{
number=-number;
SerialSendByte('-');
}
while(div>1&&div>number)
div/=10;
do
{
SerialSendByte(dec[number/div]);
number%=div;
div/=10;
}
while(div);
}
void SendECG() //Send ECG DATA
{
for (m=0;m<63;m++)
{
SerialSendInt(ECG[m]);
}
SerialSendByte(0x0D);
Delay();
SerialSendByte(0x0A);
Delay();
}
/*--------------------------*/
void Delay(void)//Delay
{
unsigned int d;
for(d=1;d<65535;d++);
}
void main()
{
Uart_init();
Modem_Init();
SendECG();
while(1)
{
}
}
|