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.

Problem interfacing with GSM Modem - MSP430 UART

Other Parts Discussed in Thread: MSP430G2553, MAX3232

Hi all,

My problem:

I am pulling my hair out of frustration now, due to the fact that I cannot get any reasonable communication going with my MSP430 LaunchPad, and the GSM Modem that I got. Whatever I send to the Modem, it seems to echo back the last two characters sent to it. So if I send:

"AT\r" --> I receive back "AT"

"AT+IPR?\r" --> I receive back "R?" and so on...

Please note that I have tested my UART code on the MSP430 with PC already - I can successfully transmit and receive full strings.

My setup:

* The MSP430 LaunchPad has a MSP430G2553 MCU, powered by a USB port. The UART jumpers are in HW position.

* The GSM modem I got is: GPRS Shield V2.0 from Seeeduino. The uart jumpers are in the position as shown here: http://www.seeedstudio.com/wiki/images/9/95/GPRS_communicate_with_arduino_with_hardware_serial.jpg

* I have connected the TXD from MSP to RXD (Pin 0) on the Shield, and RXD from MSP to TXD (Pin 1) on the shield.

What is the issue here? Do I need to possibly connect the ground of the MSP430 board to the ground of the GPRS Shield??

 

  • Hi,

    Is it possible the GSM modem requires flow control of some sort (Xon/Xoff)?  Sounds like there is two stage buffer on the modem and all of the first characters sent are overwritten by the last two.


    HTH,

    Barry

  • Of course you have to connect both grounds together.

  • Yes, MSP and modem require a common GND connection. Not necessarily the shield, but at least the data GND.
    However, check the required signal levels. Most modems require RS232 level signals, while the MSP sends/requires TTL level signals. When connecting the LaunchPad to the PC using the application UART, the TUSB USB/ser bridge chip on the LaunchPad will take TTL levels. A real PC COM port (and likely your modem) won’t. In this case you’ll need a converter like the MAX3232.
    It's possible that the modem simply echoes the incoming signal levels without recognizing them as data at all. (I remember those modems with auto-baudrate detection did, echoing verything 1:1 and just adapting to the baudrate when a 'AT' was properly recognized). In this case, yll you get 'returned' from the mode woudl be an "analog echo"

  • Hi all,

    Thank you very much for the replies. It turns out the cause was indeed the missing GND connection. The modem is now communicating with the MSP430.

  • sir I am facing the problem with msp430 and GSM. I will clearly describe my situation.
    I am able to make call and send SMS through at commands from GSM module using msp430.
    But the problem is when I am doing reverse way i.e calling from cell to GSM msp430 is not responding to that.
    Can you please help me out sir????
  • If you can send, then at least the MSP and the modem are running and the TX conenction is working.
    Buw why th eopposite side doesn't work will remain a mystery without more information. That is: schematics, code, maybe scope or logic analyzer captures form the signals.
    Also 'not responding' can mean a lot. Does it not notice the incoming SMS or does it just not properly answer? How does/shall it notice? I'm no GSM modem expert(never worked with one) , so I don't know how incoming SMS is handled by the modem.
  • Sir my coding is fine!! I will post the code I am able to print AT commands on putty using msp430g2553. Also I am able to make call and send SMS by sending AT commands through putty. So basically GSM is fine but the problem is when I connect msp430g2553 to GSM I am able to see At commands on serial monitor but the response is Error. Can u help me out what might be the problem?
  • #include <msp430g2553.h>

    int value;

    char str[2];

    void my_itoa(unsigned int num, char *str)

    {

        unsigned char rem = 0;

        char *temp = str;

        char *str1 = str;

        char temp1;

     

        if (num != 0)

        {

            while(num > 0)

            {

                rem = num % 10;

                *str = rem + 48;

                str++;

                num = num / 10;

            }

            *str = '\0';

            str = str1;

     

            while(*temp != '\0')

            {

                temp++;

            }

            temp = temp - 1;

     

            while(temp >= str)

            {

                temp1 = *str;

                *str = *temp;

                *temp = temp1;

                str++;

                temp--;

            }

        }

        else

        {

            *str = 48;

            str++;

            *str = '\0';

        }

    }

     

    int uart_putchar(char c)

    {

        /* Wait for the transmit buffer to be ready */

       while (!(IFG2 & UCA0TXIFG));

     

        /* Transmit data */

        UCA0TXBUF = (char ) c;

     

        return 0;

    }

     

    int getch(void)

    {

        int chr = -1;

     

        while(!(IFG2 & UCA0RXIFG));

     

        chr = UCA0RXBUF;

     

     

        return chr;

    }

     

    void print(char *str)

    {

        while(*str != '\0')

        {

            uart_putchar(*str);

            str++;

        }

     

        //uart_putchar(' ');

    }

     

    int distance;

     

    int main()

    {

        if (CALBC1_1MHZ==0xFF)                  // If calibration constant erased

      {

        while(1);                               // do not load, trap CPU!!

      }

      DCOCTL = 0;                               // Select lowest DCOx and MODx settings

      BCSCTL1 = CALBC1_1MHZ;                    // Set DCO

      DCOCTL = CALDCO_1MHZ;

      P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD

      P1SEL2 = BIT1 + BIT2 ;                    // P1.1 = RXD, P1.2=TXD

      UCA0CTL1 |= UCSSEL_2;                     // SMCLK

      UCA0BR0 = 104;                            // 1MHz 9600

      UCA0BR1 = 0;                              // 1MHz 9600

      UCA0MCTL = UCBRS0;                        // Modulation UCBRSx = 1

      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**

        char distance_str[10];

        char sum, checksum;

        int i,j,k;

     

        unsigned int l;

     

     

        // Disable watchdog timer

        WDTCTL = WDTPW + WDTHOLD;

     

     

        P1DIR = 0b01001001;

     

     

        TA1CTL = TASSEL_2 + ID_0 + MC_2;

        // Now just monitor distance sensor

        while(1)

        {

                            P1OUT^=BIT0;

                               print((char *)"AT");

                               uart_putchar(0x0A);

                               uart_putchar(0x0D);

                               __delay_cycles(1000000);

     

                               print((char *)"ATD9743172765;");

                                 uart_putchar(0x0A);

                                 uart_putchar(0x0D);

                                 __delay_cycles(60000000);

     

                                 __delay_cycles(600000000);

    }

    }

  • Here's a quick experiment: Try reversing your <LF,CR> sequences to send <CR,LF> instead.

    Back in the Ancient Days, I recall encountering some AT parsers that insisted that CR is the AT command terminator (and ignored any LF that followed), and would fumble if the LF were sent first. I then got in the habit of sending the CR first, so I don't know if that has changed.

    Of course if your Book says the LF must come first then I defer.
  • All terminal devices (or programs referring to a double-character line-end sequence, including the standard C console I/O) use CR/LF. I've never seen any program using LF/CR, even though this will have the same effect (go to start of next line) on a plain dumb line printer or terminal output.
    So your 'habit' is actually the established standard. :)
    If the book says something else, then this is more than unusual (and probably wrong).

**Attention** This is a public forum