Home › Forums › Microcontrollers › PIC Microcontroller › gsm with PIC controller › Reply To: gsm with PIC controller
August 28, 2017 at 4:03 pm
#13904
ykn
Participant
#define TRUE 1
#define bool_val_1 flags. f0
#define LCD_DIR TRISD
#define CTRL_DIR TRISB
#define LCD PORTD
#define RS PORTB.F0
#define E PORTB.F1
/////////////////////////////////////////////////////
#include"lcd.h"
int flag=0,gps_flag=1;
int i=0;
int k;
char send_data();
char response[70]="";
void main()
{ CTRL_DIR=0X00;
LCD_DIR=0X00;
UART1_Init(2400); // Initialize UART module at 9600 bps
Delay_ms(1000);
/*Soft_UART_Init(&PORTD, 0, 1, 9600, 0);
delay_ms(500);*/
init_lcd() ;
delay_ms(500);
UART1_Write_Text("ATE0\r\n");
delay_ms(500);
UART1_Write_Text("AT\r\n");
delay_ms(500);
while(gps_flag)
{
if(gps_flag)
{
send_data();
}
for(k=0;k++;k<70)
{
response[k]="\0";
}
}
}
char send_data()
{
char flags;
char byte;
int k;
char num[10];
bool_val_1 = TRUE;
UART1_Write_Text("AT+CPBR=3\r\n");
delay_ms(250);
cmd_lcd(0x80);
string_lcd("AT+CPBR=3") ;
while(UART1_Data_Ready()>0)
{
byte=UART1_Read();
response[i]=byte;
delay_ms(1000);
//string_lcd(response[i]);
++i;
}
delay_ms(1000);
if(bool_val_1)
{
//UART1_Write_Text(response) ;
cmd_lcd (0x01); // lcd clear command
delay_ms(5);
string_lcd(response);
delay_ms(1000);
//Soft_UART_Write(response);
for(K=4;k++;k>17)
{
num[k-4]=response[k] ;
}
}
//return ;
}