#include <usart.h>
void UART2_Write_Text(char text[]){
unsigned int i = 0;
while(text[i])Write2USART(text[i++]);
}
void GSM_Send(char min){
unsigned char spbrg = 25;
unsigned char Command_AT[] = "AT\r\n";
unsigned char Command_CMGF[] = "AT+CMGF=1\r\n";
unsigned char Command_CMGS[] = "AT+CMGS=\"+94774944647\"\r\n";
unsigned char msg01[] = "Hello!";
unsigned char CtrlZ = 0x1A;
unsigned int i = 0,j = 0;
TXSTA2bits.TXEN = 1;// Activate Transmission
TXSTA2bits.SYNC = 0;//Asynchronus full duplex
RCSTA2bits.SPEN = 1; // To activate serial port (Tx and Rx pins)
RCSTA2bits.CREN = 1; // Activate Reception
while(1){
Init_Delay();Init_Delay();Init_Delay();Init_Delay();Init_Delay();
Open2USART(USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW, 207);
baud2USART (BAUD_8_BIT_RATE | BAUD_AUTO_OFF);
Init_Delay(); //1 sec delay
while(Busy2USART());
UART2_Write_Text(Command_AT);
Init_Delay(); //1 sec delay
UART2_Write_Text(Command_CMGF);
Init_Delay();Init_Delay(); //2 sec delay
UART2_Write_Text(Command_CMGS);
Init_Delay();Init_Delay();Init_Delay();Init_Delay();Init_Delay(); //5 sec delay
UART2_Write_Text(msg01);
Init_Delay(); //0.3 sec delay
Write2USART(CtrlZ);
Write2USART(13);
Write2USART(10);
}
}