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 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