It is currently 16 Oct 2018 13:00

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 27 Aug 2017 19:50 
Offline

Joined: 27 Aug 2017 19:28
Posts: 18
hi all,
i am new one with UART. i have interface gsm with pic controller and my objective is to read the specific number from sim card and display on it lcd .
for that i used command =>AT+CPBF="NAME"
and UART libray in MIkroc pro, but am not getting output. i do nt understand where i am wrong, i am posting my code below
#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(9600);              // Initialize UART module at 9600 bps
     Delay_ms(5000);
     /*Soft_UART_Init(&PORTD, 0, 1, 9600, 0);
     delay_ms(500);*/
     init_lcd() ;

     /*UART1_Write_Text("AT+CGNSPWR=1\n\r");
     delay_ms(1000);
     cmd_lcd(0x80);
     string_lcd("AT+CGNSPWR=1")  ;
     delay_ms(1000);
     UART1_Write_Text("AT+CGPSOUT=32\n\r");
     delay_ms(500);
     cmd_lcd(0x80);
     string_lcd("AT+CGPSOUT=32")  ;
     //UART1_Write_Text("AT+CPBR=3\r\n");
     delay_ms(1050);*/
     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+CPBF=Daniel");
       delay_ms(1000);
       cmd_lcd(0x80);
       //string_lcd("AT+CGPSOUT=32")  ;
       while(UART1_Data_Ready())
                                {
                                byte=UART1_Read();
                                response[i]=byte;
                                //Soft_UART_Write(response[i]);
                                delay_ms(1000);
                                string_lcd(response[i]);
                                i++;

                                }
         delay_ms(5000);
         if(bool_val_1)
         {
          UART1_Write_Text(response)  ;
          string_lcd(response);
         // Soft_UART_Write(response);
          for(K=4;k++;k>17)
          {
           num[k-4]=response[k] ;
          }
         }
         i=0;
        return ;
 } please look over the code and help me


Top
 Profile  
 
PostPosted: 12 Sep 2017 18:15 
Offline
User avatar

Joined: 21 Mar 2017 16:57
Posts: 527
aHello,

First of all, sorry for the late reply
Second, the best way to troubleshoot your issue is to print things onto UART terminal and write back the responses with the keyboard and send back - terminals integrated in our compilers do a good job for that purpose.This way you'd mimic the behavior of the hardware. Make sure that you can parse commands correctly. Then if this is good, check that you are using the correct baud rate to communicate with the module...

I hope this helps
Best regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: