-->
Page 1 of 1

A6 GSM Module controll from PIC18F MCU

PostPosted: Thu Sep 01, 2016 2:40 pm
by dtvonly
Hi. I have an A6 GSM module that works great via USB to Serial bridge from the laptop. I am able to send and receive text using the three simple following commands:
1) AT+CMFG=1 <CR>
2) AT+CMGS="8881234567" <CR> // this is the phone number in the US
3) "the text message goes here$1A" <CR> // CRTL-Z then <CR>

all worked well from the laptop. However, I tried sending the "same" command from the PIC18F microcontroller the three commands above, nothing happens.

Hardware info:
A6 GSM default baud: 115200
PIC18F baud: 115200

Code: Select all//////////////////////////////////////////////////////////////////
//  Setting up:  115200,n,8,1 RS-232 protocol                     //
//  SPBRG = [Fosc/(BAUD*16)] - 1.  Current Fosc=8MHz            //
//  Fosc            Baud            SPBRG1                      //
//  16MHz           9600            103                         //
//   8MHz         115200         3 ---> for use with A6 GSM   //
//  8MHz            9600            51                          //
//  1MHz            9600            5                             //
//////////////////////////////////////////////////////////////////
void Init_USART()
{
    SPBRG1 = 3;                        // 115200,n,8,1 at 8HMz
//    SPBRG1 = 51;                     // 9600,n,8,1 at 8MHz
    TXSTA1bits.TXEN = 1;                      // TX enable.
    TXSTA1bits.SYNC = 0;               // Asynchronous; 8-bit
    RCSTA1bits.SPEN = 1;               // USART Serial (RC6=TX, RC7=RX) ON
    BAUDCONbits.BRG16 = 0;               // Baud rate from SYNC=0, BRG16=0, BRHG=1 settings
    TXSTA1bits.BRGH = 1;                // high speed mode ON
   
    RCSTA1bits.CREN = 1;                    // continuous receive ON
    TRISCbits.TRISC7 = 1;               // RX1 USART.
    TRISCbits.TRISC6 = 0;               // TX1 USART.
    PIE1bits.RC1IE = 0;                     // USART1 RX interrupt OFF.
    PIR1bits.RC1IF = 0;                  // Clear received buffer flag.
}


My only concern now is that I am not terminating the commands correctly.
In C code I have tried sending at the end of each command a 0x0D (carriage return).
When this did not work, I would embed the \r in the command string:
char my_msg[] = "AT+CMGF=1\r";
This did not work also.
When I debugged the code, I did see the correct characters sending out.
Please see attachment and advise. Thank you.