Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem in AT+CPBR Command with PIC18F452

Status
Not open for further replies.

speedEC

Full Member level 6
Joined
Apr 1, 2011
Messages
337
Helped
23
Reputation
46
Reaction score
21
Trophy points
1,298
Activity points
4,324
Dear all,

I can able to send and receive all AT Commands except (AT+CPBR and AT+CMGR Commands). I want to store all the phone book entries (already stored in SIM) into array. So, When I start the GSM Modem/Module, I issue AT+CPBR=1,250 command and read the Phone Book (SIM) and Store the Phone numbers into the array. If I issue AT+CPBR command, it executes well and return the phone book records and hangs. I don't know why. All other commands work fine. Any help? I give you my code here. Pl go thro' that and pl let me know if you found any errors. The code could be little large. Inconvenience regretted.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* MAKE RECEIVE AS HIGH INTERRUPT PRIORITY */
#pragma code rx_interrupt = 0x8 //high interrupt vector
void rx_int (void)
{
    if (PIR1bits.RCIF){
        PIR1bits.RCIF = 0; // clear interrupt flag
        rx_handler();
    }
    return;
}
#pragma code
 
#pragma interrupt rx_handler // changed the interrupt to interruptlow
void rx_handler (void)
{
  unsigned char input;
  
  input = ReadUSART();
    
    switch(input){
            
            case '\x0A': // if line feed detected in the GSM output i.e. '\n'
                        break;
            case '\x0D': // if carriage return detected i.e. '\r'
                        gsmOutput_c[i] = '\x00';
                        
                        lenOfGSMOutput = strlen((char*)gsmOutput_c);
                        if (lenOfGSMOutput > 0){
                            i = 0;
                            lenOfGSMOutput = 0;
                            
                            showGSM_DATA(gsmOutput_c);
                            *gsmOutput_c = 0;
                            
                            PIE1bits.RCIE = 1; // enable receive interrupts
                            
                        }
                        break;
                                    
        default: // if characters received
                        if(i < 80){
                            gsmOutput_c[i] = input;
                            i++;
                        }
                        else{
                            i = 0;
                        }
                break;
        }//end for switch
}
 
//Processing and Validating GSM_MODEM_OR_MODULE OUTPUT
 
void showGSM_DATA(char gsmOutput_s[]){
    
    if (strcmppgm2ram(gsmOutput_s, (const far rom char*)"OK") == 0){
       OK = TRUE;
    }
    if (strcmppgm2ram(gsmOutput_s, (const far rom char*)"ERROR") == 0){
       OK = FALSE;
     return;
    }
            
    if (strcmp(gsmOutput_s, NO_CARRIER) == 0){
        WriteCmdXLCD(CLR_LCD); 
        while(BusyXLCD()); 
        WriteCmdXLCD(HOME_LCD); 
        while(BusyXLCD()); 
        putrsXLCD("NO CARRIER");
     return;
    }
    
    if (strcmp(gsmOutput_s, Error) == 0) {
        WriteCmdXLCD(CLR_LCD); 
        while(BusyXLCD()); 
        WriteCmdXLCD(HOME_LCD); 
        while(BusyXLCD()); 
        putrsXLCD("Error");
     return;
    }
    
    if (strcmppgm2ram(NextGSMCmd, (const far rom char*) "PhBk_Stored") == 0){
        
        *NextGSMCmd = 0;
        *gsmOutput_s = 0;
        
        WriteCmdXLCD(CLR_LCD); 
        while(BusyXLCD()); 
        WriteCmdXLCD(HOME_LCD); 
        while(BusyXLCD());
        
        if (OK == TRUE){
            OK = FALSE;
            putrsXLCD("PH BK READ - OK");
        }
        else{
            putrsXLCD("PH BOOK ERROR");
        }
     return; 
    }
    
    if (strlen(gsmOutput_s) > 5){
        
        strBuff = 0;
        i = 0;
        
        while(i < 5){
            strBuff[i] = gsmOutput_s[i];
            i++;
        }
        strBuff[i] = '\x00';
        i = 0;
        
        if (strcmppgm2ram(strBuff, (const far rom char*)"+CPBR") == 0){
            
            *strBuff = 0;
            if (strcmppgm2ram(NextGSMCmd, (const far rom char*) "store_PhBk_Into_Array") == 0){
                strcpypgm2ram(NextGSMCmd, (const far rom char*) "PhBk_Stored");



Here the problem araises. If I commented as follows it works fine. But, If I uncomment the following XLCD commands "gsmOutput_s" displayed correctly and hangs here.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
                *gsmOutput_s = 0;
                WriteCmdXLCD(CLR_LCD); 
                while(BusyXLCD()); 
                WriteCmdXLCD(HOME_LCD); 
                while(BusyXLCD()); 
                putrsXLCD("gsmOutput_s");
               */
            }
          return;
        }
    } 
}
 
void main (void)
{
 
    TRISA = 0; // RS, R/W, E pins of LCD
    /* Configure all PORTB pins for output except RB0*/
    TRISB = 0; // RB0 as Input for Interrupt
    TRISD = 0; // set PORTD as Output for LCD (D4 to D7) 
    PORTB = 0; // Initialize portB
    PORTD = 0; // Initialize PORTD
    
    /* Make receive interrupt high priority */
    IPR1bits.RCIP = 1;
    
    /* Enable interrupt priority */
    RCONbits.IPEN = 1;
    /* Enable all high & low priority interrupts */
    INTCONbits.GIEH = 1;  // interrupt on RB0
    
    OpenXLCD(FOUR_BIT & LINE_5X7); // Open and Initialize LCD
    
    /*
    * Open the USART configured as
    * 8N1, 9600 baud, in polled mode
    */
    OpenUSART (USART_TX_INT_OFF &    //Set and Open Serial Port
               USART_RX_INT_ON &
               USART_ASYNCH_MODE &
               USART_EIGHT_BIT &
               USART_CONT_RX &
               USART_BRGH_HIGH, 25);
    
    i = 0;
    
    OK = FALSE;
    strcpypgm2ram(NextGSMCmd, (const far rom char*) "store_PhBk_Into_Array");
    
    while (BusyUSART());
    putrsUSART((const far rom char *)"AT+CPBR=1");
    while (BusyUSART());
    putcUSART(0x0A);
    putcUSART(0x0D);
    
    /* Loop forever */
    while (1);
        
}




advance thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top