新手入门
- 积分
- 5
- 金钱
- 5
- 注册时间
- 2020-4-17
- 在线时间
- 2 小时
|
1金钱
#include <REG51.H>
#include <string.H>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define FOSC_110592M
//#define FOSC_12M
sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P13=P2^3;
sbit P14=P2^4;
sbit P15=P1^5;
unsigned int rec_data_len_uart=0;
unsigned char idata Buffer_Uart0_Rec[25]={0};
void SerialInti()
{
TMOD=0x20;
#ifdef FOSC_12M
TH1=0xf3;
TL1=0xf3;
#else
TH1=0xfd;
TL1=0xfd;
#endif //end of SOC_12M
TR1=1;
SM0=0;
SM1=1;
REN=1;
EA=1;
ES=1;
}
void Serial_interrupt() interrupt 4
{
unsigned char temp_rec_data_uart0;
temp_rec_data_uart0 = SBUF;
RI=0;
Buffer_Uart0_Rec[rec_data_len_uart]=temp_rec_data_uart0;
rec_data_len_uart++;
if(rec_data_len_uart>24)
{
rec_data_len_uart=0;
}
}
void Uart1Send(uchar c)
{
SBUF=c;
while(!TI);
TI=0;
}
void Uart1Sends(uchar *str)
{
while(*str!='\0')
{
SBUF=*str;
while(!TI);
TI=0;
str++;
}
}
void DelaySec(int sec)
{
uint i , j= 0;
for(i=0; i<sec; i++)
{
for(j=0; j<65535; j++)
{
}
}
}
void main()
{
uchar i = 0;
SerialInti();
DelaySec(10);
P14=0;
Uart1Sends("AT+CMGF=0\r\n");
DelaySec(1);
Uart1Sends("AT+CSCS=\"USC2\"\r\n");
DelaySec(1);
Uart1Sends("AT+CSCA?\r\n");
DelaySec(1);
Uart1Sends("+CSCA:\"002B0038003600310033003800300030003700350034003500300030\",145\r\n");
DelaySec(1);
Uart1Sends("AT+CMGS=23\r\n");
DelaySec(1);
Uart1Sends("0011000D91688121150710F700080108521B601D901A4FE1");
DelaySec(1);
Uart1Sends("+CMGS: 10\r\n");
DelaySec(1);
Uart1Send(0X1A);
DelaySec(15);
P13=0;
while(1);
}
这是我的程序,试过打电话可以,那就应该是程序的问题,请问是我哪里写的不规范吗,求教
|
|