#include "main.h"
main()
{
Init_usart();
Init_main();
for(;;)
{
if(RB5==0)
{
SendAT_command();
}
}
}
void Init_usart()
{
RCSTA=0b10000000;
TXSTA=0b00100100;
SPBRG=12;
INTCON=0b11000000;
RCIE=0;
return;
}
void Init_main()
{
PORTA=0x00;
CMCON=0b00000111;
TRISA=0x00;
TRISB=0b00100010;
STATUS=0x00;
return;
}
void SendAT_command()
{
//char dial1[9]={'A', 'T', 'D', '›', 'S', 'M', '1', ';', '\n'};
int dial1[9]={0x41,0x54,0x44,0x3e,0x53,0x4d,0x31,0x3b,0x0d};
int i;
for(i=0;i‹9;i++)
{
for(;;)
{
if(TXIF==1) break;
}
TXREG=dial1[i];
}
for(;;)
{
if(RB5==1) break;
}
Read_comand();
return;
}
void Read_comand()
{
int read[5];
int i=0;
int b=0;
unsigned int address=0x00;
CREN=1;
for(;;)
{
if(RCIF==1)
{
i++;
read[i]=RCREG;
}
if(i==5) break;
}
CREN=0;
while(b‹=5)
{
address++;
EEPROM_WRITE(address,read[b]);
b++;
}
EEPROM_WRITE(0x20,12);
return;
} |