hi all, i need a small help from you all... i am trying to interface GSM module with 89E516RD2 microcontroller. and receive messages and display the content of message to the LCD.. i have written a basic code to test it.... but the things are not working proper... can anybody please let me know where the mistake is...
#include<P89V51Rx2.h> sbit LCD_en=P0^1; sbit LCD_rs=P0^0; #define LCD_DELAY 800 /* Delay for 1 ms */ #define lcdclear() LCD_command(0x1) /* Clear display LCD */ #define LCD_origin() LCD_command(0x2) /* Set to origin LCD */ #define lcdrow1() LCD_command(0x80) /* Begin at Line 1 */ #define lcdrow2() LCD_command(0xC0) /* Begin at Line 2 */ #define lcdrow3() LCD_command(0x94) /* Begin at Line 3 */ #define lcdrow4() LCD_command(0xD4) /* Begin at Line 4 */ #define Shiftcursorleft() LDC_command(0x04) void LCD_delay(unsigned char ms); void LCD_enable(); void LCD_command(unsigned char command); void LCD_putc(unsigned char ascii); void LCD_puts(unsigned char *lcd_string); void LCD_init(); void uartinit(); void cmd(unsigned char cd); void lcd_datawrt(unsigned char *msg); unsigned char getdat(void); void dat(unsigned char dt); void delay (unsigned int t); void main() { unsigned char i,msg[50]; uartinit(); LCD_init(); while(1) { lcdrow1(); LCD_puts("WAITING FOR MSG");//wait while((getdat())!=':'); while((getdat())!='+'); while(getdat()!='\n'); for(i=0;i<20;i++) { msg[i]=getdat(); if(msg[i]=='\r') break; } msg[i]='\0'; lcdrow1(); LCD_puts(msg);//wait } } void uartinit(void) //uart initialising { TMOD=0x20; TH1=0x0FD;//9600 baud rate SCON=0x50; TR1=1; } unsigned char getdat(void) //receive gps data serially { unsigned char a; while(RI==0); a=SBUF; RI=0; return(a); } void LCD_delay(unsigned char ms) { unsigned char n; unsigned int i; for (n=0; n<ms; n++) { for (i=0; i<LCD_DELAY; i++); /* For 1 ms */ } } void LCD_enable() { LCD_en = 0; /* Clear bit P2.4 */ LCD_delay(1); LCD_en = 1; /* Set bit P2.4 */ } void LCD_command(unsigned char command) { LCD_rs = 0; /* Clear bit P2.5 */ P1 = (P1 & 0xF0)|((command>>4) & 0x0F); LCD_enable(); P1 = (P1 & 0xF0)|(command & 0x0F); LCD_enable(); LCD_delay(1); } void LCD_putc(unsigned char ascii) { LCD_rs = 1; /* Set bit P2.5 */ P1 = (P1 & 0xF0)|((ascii>>4) & 0x0F); LCD_enable(); P1 = (P1 & 0xF0)|(ascii & 0x0F); LCD_enable(); LCD_delay(1); } void LCD_puts(unsigned char *lcd_string) { while (*lcd_string) { LCD_putc(*lcd_string++); } } void LCD_init() { LCD_en=1; /* Set bit P2.4 */ LCD_rs=0; /* Clear bit P2.5 */ LCD_command(0x33); LCD_command(0x32); LCD_command(0x28); LCD_command(0x0C); LCD_command(0x06); LCD_command(0x01); /* Clear */ LCD_delay(256); }
"The display and all are working perfect." would indicate that everything works. So be happy.
Yes everything is working perfect.... Except Gsm module. I can send messages and also receive it but am bot able to read it on LCD. That's what my problem is. If can then please help me.
So - have you made any attempts at all to verify if the serial interface works? Where is your code that sends strings to the module and verifies that you can get responses?
And your code to get a message and print is a bit boring - what if the module prints some other string?
Yes... I have tried sending message with some other code.... It was working.
Microcontroller 89E516RD2 vs #include<P89V51Rx2.h>
Are these microcontrollers compatible in every sense ? Clock, pinout, Special Function Registers ... ?
The data sheet of both microcontroller SST89E516RD2 and P89V52RD are same as well as pin out, clock frequency. If not... Them can you please let me know what should i use
I got this details from google...
SST89E516RD2-40-C-NJE- Microchip - 40 Pin PDIP - 8051 Core Microcontroller - Replaces NXP P89V51RD2 The SST SST89x516RD2 is an 8051 based microcontroller with Embedded Flash Memory, 3 16-bit Timers, UART, WDT, PCA, 32 I/O pins, Dual Data Pointers, SPI etc. It's a 100% Pin drop replacement to NXP's P89V51RD2 microcontroller, It has inbuilt bootloader and does not require any external programmer to update flash.
All codes written for P89V51RD2, as well as all the hardware designed for P89V51 are fully compatible to this microcontroller. It can be programmed easily using Serial [RX, TX, GND] protocol using EasyIAP software. The good news is Keil uVision C51 compiler supports and provide extension to develop products using SST89E516RD2 controller.
still do i need to change the header file..????
"Yes... I have tried sending message with some other code.... It was working."
And what have you tried with this code?
Software development isn't just about writing a number of source code lines. It also includes planning and design before you start. And it includes debugging of the code you have written. And then you need to document and set up test cases etc.
You haven't indicated that you have done anything at all to try to figure out where it goes wrong.
Not familiar with the SIM800, but every other GSM modem I've used you have to walk it through a bunch of AT commands to get SMS messages out in ASCII
If debugging on embedded is to difficult, would recommend connecting modem to a PC and coding/testing code to interact with it there.