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.

CCS/MSP430FR4133: Trying to transmit data via SIM800 GSM module

Part Number: MSP430FR4133

Tool/software: Code Composer Studio

Hi,

   i am using a MSP430FR4133 launch pad. I am trying to give AT commands to GSM module from MSP430FR4133LP and get the corresponding response. But when i transmit "AT\r\n" i just receive a space(0x000A) in the Receive bufffer. and if i try to save the received characters in a character array one by one using for loop or interrupt , it just showing zero value. the ultimate need is , sending SMS from the SIM800L. The code i am using is attached below

#include <msp430.h>
#include <String.h>
#include <stdint.h>
#include <stdlib.h>
void UART_TX();
void Init_GPIO();
//const char TXData = 'AT';

unsigned char ctrlz = (char)26;
unsigned char at[4] = {"AT\r\n"};
unsigned char cmgf[13] = {"AT+CMGF=1\r"};
unsigned char cmgs[30] = {"AT+CMGS=\"+918015989208\"\r"};
unsigned char msg[10] = {"hello\r"};
unsigned char RXData;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

int index = 0, i = 0;
long int k = 0;
int ind = 0;

unsigned char tmpLatLong[10] = {0};
unsigned char txfrBuffer[1]='a';
// Configure GPIO
Init_GPIO();
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate 1previously configured port settings

__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL0 = 0; // clear DCO and MOD registers
CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first
CSCTL1 |= DCORSEL_3; // Set DCO = 8MHz
CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
// default DCODIV as MCLK and SMCLK source

// Configure UART pins
P1SEL0 |= BIT0 | BIT1; // set 2-UART pin as second function

// Configure UART
UCA0CTLW0 |= UCSWRST;
UCA0CTLW0 |= UCSSEL__SMCLK;

// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// User's Guide Table 14-4: UCBRSx = 0x49
// UCBRFx = int ( (52.083-52)*16) = 1
UCA0BR0 = 52; // 8000000/16/9600
UCA0BR1 = 0x00;
UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA0IE = UCTXIE | UCRXIE; // Enable USCI_A0 RX interrupt

while(!(UCA0IFG&UCTXIFG));

Uart_TXn(&at[0],4);
k = 200000;
do{
--k;
} while(k > 0);
// Uart_TXn(&cmgf[0],sizeof(cmgf));
// k = 200000;
// do{
// --k;
// } while(k > 0);
//
// Uart_TXn(&cmgs[0],sizeof(cmgs));
// k = 200000;
// do{
// --k;
// } while(k > 0);
//
// Uart_TXn(&msg[0], sizeof(msg));
// k = 2000000;
// do{
// --k;
// } while(k > 0);
//
// Uart_TXn(&ctrlz, sizeof(ctrlz));
// k = 200000;
// do{
// --k;
// } while(k > 0);
while(1);

//__bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled
// __no_operation(); // For debugger
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA0IFG&UCRXIFG));
RXData = UCA0RXBUF;
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}

void Init_GPIO()
{
P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;
P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;
P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;
P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;
}

void Uart_TXn( unsigned char *str, int size)
{
int i = 0;
while(size > 0)
{
UCA0TXBUF = str[i++];
while(!(UCA0IFG & UCTXIFG));
size--;
}
}

is there any examples for sending SMS using SIM800L from MSP430FR4133 in CSS using register level program ??..

Thank you in advance...

  • Hi Kamalesh,

    I would recommend that you approach this in a different way:
    * Without the GSM module, confirm that your MCU / RxTx is working correctly by testing your circuit / code with an echo setup (Tx connected to Rx).
    * Without the MCU circuitry, connect the GSM module to a serial terminal using an adapter (USB-RS232, etc..) and issue the AT commands through the terminal to confirm the module is performing as expected.
  • Hi Mike Tooma ,
    I have checked the GSM module with an Arduino its working fine and also I have tried transmitting string from MSP430 to Arduino via TX RX that is also working fine. But the thing is when i tried to give AT commands to GSM , I am not able to figure out how the values are stored in the receive buffer but at the end the values stored in the transmit buffer and receive buffer is same and the SMS is not sent.
  • Hi Kamalesh,

    You shouldn't use "while(!(UCA0IFG&UCRXIFG));" in a interrupt ISR.  You can use a array to store the receive data and check if it's correct. There is a USB to Serial tool in MSP430FR4133 LaunchPad. You can use it and serial terminal in PC to confirm both LaunchPad and the GSM module are performing as expected. Make sure the values of receiving and sending are correct.

    If my post helped solve your issue, please click on the  VERIFY ANSWER    button. 

    Winter,

    Search E2E! Your questions may already be answered! 

  • hi Winter Yu,

    I have tried with the same code , Now I am receiving a SMS in my Mobile but i am just receiving a blank message....
    and thank you for replying.....

    #include <msp430.h>
    #include <String.h>
    #include <stdint.h>
    #include <stdlib.h>

    void Init_GPIO();
    void Uart_TXn();
    //const char TXData = 'AT';

    unsigned char ctrlz = (char)26;
    unsigned char at[4] = {"AT\r\n"};
    unsigned char cmgf[13] = {"AT+CMGF=1\r"};
    unsigned char cmgs[30] = {"AT+CMGS=\"+918015989208\"\r"};
    char* msg = "hello";
    unsigned char RXData;
    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    int index = 0, i = 0;
    long int k = 0;
    int ind = 0;

    unsigned char tmpLatLong[10] = {0};
    unsigned char txfrBuffer[1]='a';
    // Configure GPIO
    Init_GPIO();
    PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
    // to activate 1previously configured port settings

    __bis_SR_register(SCG0); // disable FLL
    CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
    CSCTL0 = 0; // clear DCO and MOD registers
    CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first
    CSCTL1 |= DCORSEL_3; // Set DCO = 8MHz
    CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
    __delay_cycles(3);
    __bic_SR_register(SCG0); // enable FLL
    while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

    CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
    // default DCODIV as MCLK and SMCLK source

    // Configure UART pins
    P1SEL0 |= BIT0 | BIT1; // set 2-UART pin as second function

    // Configure UART
    UCA0CTLW0 |= UCSWRST;
    UCA0CTLW0 |= UCSSEL__SMCLK;

    // Baud Rate calculation
    // 8000000/(16*9600) = 52.083
    // Fractional portion = 0.083
    // User's Guide Table 14-4: UCBRSx = 0x49
    // UCBRFx = int ( (52.083-52)*16) = 1
    UCA0BR0 = 52; // 8000000/16/9600
    UCA0BR1 = 0x00;
    UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

    UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
    UCA0IE = UCTXIE | UCRXIE; // Enable USCI_A0 RX interrupt

    while(!(UCA0IFG&UCTXIFG));

    Uart_TXn(&at[0],4);
    k = 200000;
    do{
    --k;
    } while(k > 0);
    Uart_TXn(&cmgf[0],sizeof(cmgf));
    k = 200000;
    do{
    --k;
    } while(k > 0);

    Uart_TXn(&cmgs[0],sizeof(cmgs));
    k = 200000;
    do{
    --k;
    } while(k > 0);

    Uart_TXn(&txfrBuffer[0], sizeof(txfrBuffer));
    k = 2000000;
    do{
    --k;
    } while(k > 0);

    Uart_TXn("\r", sizeof("\r"));
    k = 2000000;
    do{
    --k;
    } while(k > 0);

    Uart_TXn(&ctrlz, sizeof(ctrlz));
    k = 200000;
    do{
    --k;
    } while(k > 0);
    while(1);

    //__bis_SR_register(LPM3_bits|GIE); // Enter LPM3, interrupts enabled
    // __no_operation(); // For debugger
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
    {
    case USCI_NONE: break;
    case USCI_UART_UCRXIFG:
    while(!(UCA0IFG&UCRXIFG));
    RXData = UCA0RXBUF;
    __no_operation();
    break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
    default: break;
    }
    }

    void Init_GPIO()
    {
    P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;
    P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;
    P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
    P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
    P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;
    P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;
    }

    void Uart_TXn( unsigned char *str, int size)
    {
    int i = 0;
    while(size > 0)
    {
    UCA0TXBUF = str[i++];
    while(!(UCA0IFG & UCTXIFG));
    size--;
    }
    }
  • Hi ,

    It seems your uart data communication layer have no problem (assume you have checked it). So you should further check your communication protocol with SIM800 GSM module. Another path is comparing the content sending by Arduino and MSP430.

    If my post helped solve your issue, please click on the  VERIFY ANSWER    button. 

    Winter,

    Search E2E! Your questions may already be answered! 

**Attention** This is a public forum