#include <usart.h>
void GSM_Send(char min,char hr)
{
if (min%5==0)
{
unsigned char config=0,spbrg=0,baudconfig=0;
unsigned char Command_CMGF[]="AT+CMGF=1\r"; // AT+CMGF for selecting Text Mode
unsigned char CtrlZ=0x1A; // CTRL+Z for sedning SMS after the message has been entered
unsigned char Command_CMGS[]="AT+CMGS =+9xxxxxxxxxx\r"; // recepient mobile number
unsigned char Command_AT[]="AT\r";
unsigned int i=0,j=0;
unsigned char msg01[]="Hello! This is a test message from UART\n\r\n\r";
Close2USART();//turn off usart if was previously on
// initialize USART module - ( 8 bit, 57600 baud rate, no parity bit... )
//-----configure USART -----
config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW;
//-----SPBRG needs to be changed depending upon oscillator frequency-------
spbrg = 207; //At 4Mhz of oscillator frequency & baud rate of 9600.
Open2USART(config, spbrg); //API configures USART for desired parameters
baudconfig = BAUD_8_BIT_RATE | BAUD_AUTO_OFF;
baud2USART (baudconfig);
while(Busy2USART());
for(j=0;j<sizeof(msg01);j++)
Write2USART(msg01[j]);
Init_Delay();
//*************************************
// send data via USART
for(i=0;i<sizeof(Command_AT);i++)
Write2USART(Command_AT[i]);
//*************************************
Init_Delay();
//*************************************
// send data via USART
for(i=0;i<sizeof(Command_CMGF);i++)
Write2USART(Command_CMGF[i]);
Init_Delay();
// send data via USART
for(i=0;i<sizeof(Command_CMGS);i++)
Write2USART(Command_CMGS[i]);
Init_Delay();
Write2USART( 0x1A ); // send data via USART - ctrl+z
/*********************************************/
}
}