This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interfacing MSP430G2553 with GSM Modem

Other Parts Discussed in Thread: MSP430G2553, ENERGIA

Hi,
I am trying to interface M95 Quectel GSM Modem with MSP430G2553 on Launchpad.

I have written a basic UART program working with modem, which sends "AT\r" command and receive "OK" from modem.

The Modem is tested and working ok(separately with Hyperterminal) and so is the MSP430G2553 launchpad.


The requirements are as follows.

Baud Rate: 9600
Data bit- 8
Parity bit- None
Stop bit- 1


The communication of Launchpad with hyperterminal is working. But with Few errors:
1. The Receive buffer is not clear, so we are receiving something garbage
on first byte.
2. One byte is less shown on LCD when received response string is displayed on LCD. four bytes are being received. I can see only first three bytes.
3. Normal LCD print are working ok.


Other important points about code:
1. No low power modules are needed, its not a battery operated product.
So we used General interrupt enable function like this:
__enable_interrupt();
instead of
__bis_SR_register(LPM3_bits + GIE);

2. We used transfer function without interrupt (only flags are checked) and its working perfect.

3. The receive function we checked with flag but it had similar error and those parts of  code is commented. In current code the interrupt method is used.

I am taking reference from datasheets directly, SLAU144J-December2004-Revised July2013. pdf page 426.

Attaching the codes for reference. I am stuck since long. Please help.

Thanks & Regards, 
Apurwa

0407.UART.hLCD.h

#include  "msp430g2553.h"
#include "lcd.h"
#include "UART.h"

char response[16];

void main(void)
{

  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

  P1DIR = 0xFF;                             // All P1.x outputs
  P1OUT = 0;                                // All P1.x reset
  P1DIR = 0xFF & ~0x02;            // Set all pins but RXD to output

  P1SEL = BIT1 + BIT2 ;                        // P1.1 = RXD, P1.2=TXD
  P1SEL2 = BIT1 + BIT2 ;                       // P1.1 = RXD, P1.2=TXD
  LED_DIR = 0xFF;

     UART_init();
     LED_start_routine();
     // __enable_interrupt();
     // TimerA_UART_init();                     // Start Timer_A UART
     __enable_interrupt();
     InitializeLcm();
     ClearLcmScreen();

     LcmSetCursorPosition(0,2);
     PrintStr("REIL: WPC-02");
     LcmSetCursorPosition(1,0);
     PrintStr("  Pump Control  ");
     __delay_cycles(5000000);                    // 6 sec (approx.) wait modem to start

     LcmSetCursorPosition(0,0);
     PrintStr("UART Mode :     ");

    // LcmSetCursorPosition(1,0);
    // PrintStr("Reseting Modem     ");
    // UART_putstring("ATZ\r",4);            // WE ARE NOT RECIEVING ok OF atz , we are not concerned with it.
    // __delay_cycles(8000000);

     LcmSetCursorPosition(1,0);
     PrintStr("Echo-Off          ");
     UART_putstring("ATE0\r",5);                //we are not recieving ok for this also
     __delay_cycles(2000000);

   while(1)
     {
	 //  response[0]= 'a';

     LcmSetCursorPosition(1,0);
     PrintStr("Sent AT          ");
     UART_putstring("AT\r",3);                //we are not recieving ok for this also
     // UART_getstring(response,10);
     response[0]= UART_getchar();
     response[1]= UART_getchar();
     response[2]= UART_getchar();

     response[3]= UART_getchar();
     //response[4]= UART_getchar();
    // response[5]= UART_getchar();

     response[4]= '\0';

     LcmSetCursorPosition(1,0);
     PrintStr("Resp:            ");
     __delay_cycles(1000000);
     LcmSetCursorPosition(1,6);
     PrintStr(response);
     __delay_cycles(3000000);

     }

     while(1)
     {
      check = UART_getchar();

  	   if(check == '1')
	   {
		  UART_putstring("Received: ",10);
		  UART_putstring(response,4);
		  UART_putstring("\r\n",2);
          check='0';
	   }

     }

}


  • Apurwa,

    Apurwa said:
    The communication of Launchpad with hyperterminal is working. But with Few errors:

    If there are errors between the Launchpad and hyperterminal, I recommend starting here.

    Apurwa said:
    The Receive buffer is not clear, so we are receiving something garbage
    on first byte.

    Is the next first byte garbage, but subsequent bytes the complete expected string (i.e. the second byte is actually the first byte of the packet), or is the first byte garbage, but second and later bytes are correct and in the correct location?

    Apurwa said:
    One byte is less shown on LCD when received response string is displayed on LCD. four bytes are being received. I can see only first three bytes.

    Have you verified with a scope or LSA that all the bytes are being sent over the UART correctly?

    Apurwa said:
    So we used General interrupt enable function like this:
    __enable_interrupt();
    instead of
    __bis_SR_register(LPM3_bits + GIE);

    This is fine and accomplishes the same thing.

    Lets start with this, and see if we learn something about the other issues while debugging these.

    Mike

  • I am also facing the same issue and I am using Energia.Characters/data gets losts in serial communication like this.
    AT+CREG?

    +CREG: 0,1

    OK
    AT+CREG=?

    +CREG: (0-2)

    O
    AT+CFUN=?

    +CFUN: (0,1,4),(-)

    K


    Here the letters are missing!!!

**Attention** This is a public forum