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
#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';
}
}
}