Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved]: 8051 using read signal strength from UART using sim 300

Status
Not open for further replies.

Raj_07

Newbie level 3
Joined
May 9, 2016
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
30
Hi,

I am using 8051 microcontroller with interfacing sim 300 modem

My First aim is read signal strength from modem and show to 16*2 display.

My code is below,
My problem - The received signal strength - Not show to the display

Code:
#include<reg51.h>
#include<string.h>
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;


void gsm_init();
void lcd_comm(int comm);
void delay(int del);
void lcd_data(char *da);
void uart_init();
void uart_init();
void uart_tx(char *tr);
void uart_rx();

int count;
char rx_data[15];
char s[15];

void main()
	{
	while(1)
		{
			if(count==0)
			{
				gsm_init();
				uart_init();
				lcd_comm(0x85);
				lcd_data("	welcome	");
				lcd_comm(0xC5);
				lcd_data("	Test index	");
				uart_tx("	AT\r\n	");
				delay(1);
				uart_tx("	AT+CSQ\r\n	");
				delay(1);

				[COLOR="#FF0000"]uart_rx();[/COLOR]		 // uart received

				delay(20);
				count=1;
				break;
			}
		}
	}


void gsm_init()
	{
		lcd_comm(0x38);
		lcd_comm(0x0c);
	}

void lcd_comm(int comm)
	{
		rs=0;
		rw=0;
		P2=comm;
		en=1;
		delay(1);
		en=0;
	}

void lcd_data(char *da)
	{
		rs=1;
		rw=0;
		while(*da)
		{
			P2=*da;
			en=1;
			delay(1);
			en=0;
			da++;
		}
	}

void delay(int del)   
	{
     int i,j;
     for(i=0;i<del;i++)
     	for(j=0;j<1275;j++);
	}

void uart_init()
	{
	    TMOD=0x20;
	    TH1=0XFD;
	    SCON=0x50;
	    TR1=1;  
	    TL1=1;
	}

void uart_tx(char *tr)
	{
		while(*tr)
		{
			SBUF=*tr;
		    while(TI==0); 
		    TI=0;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           TI=0;
			tr++;
		}
	}

[COLOR="#FF0000"]void uart_rx()
	{
		int i;
		for(i=0;i<15;i++)
		{
		while(RI==0);
		rx_data[i]=SBUF; 
		RI=0;
		} 
				lcd_comm(0x01);
				lcd_comm(0x85);
				lcd_data(s);
				lcd_data("Sucess");
				lcd_comm(0xC5);
				delay(20);		
	}[/COLOR]
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top