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.

problems while receving data from 8051 though gps

Status
Not open for further replies.

kevin88

Junior Member level 1
Joined
Dec 30, 2010
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,462
Hi,

i need help on receving data from the 8051 mircocontroller interfacing with GPS. currently, i m using printf and put char to transmit data to the GPS. But when i used scanf and printf for the data output. i found out that the data does not read the whole string data but one char. may i know where will b the problem lies? thanks.. :p

void gps(void)
{
//Save Current SFR page
char SFRPAGE_SAVE = SFRPAGE;


g_uc_uart = 1;
printf("log version\r");
scanf("%s", g_s_gps_str);

printf("GPS %s", g_s_gps_str);

SFRPAGE = SFRPAGE_SAVE;
}
 

Hi ckshivaram,

I managed to send a string data through the using interrupt base. But when i look into the memory of the interrupt, i could only see 6 characters have send through which i m sending about 31 characters. From the recieved data i could only see [COM1]................................... something similar to. Due to this is a school project i could not give you the whole code. I m using UART interrupt register to transmit the characters i send and then for the received part i using getkey function. May i know whether is it the interrupt of the way i send the commands is wrong? The method i send through is using for example: log version include with CF and LF.
thanks
 

I tried it already. it does well when i connect to a PC serial port. But when i use the 8051 to send the commands, it somehow only receive 6 characters instead of 31 characters. Could it be the mircocontroller UART interrupt register could not receive the whole data or is there any way that i could receive the whole charcaters?
thanks

best regards
wei cheng
 

I m using sillicon lab mircontroller 8051. i went to check on the data sheets it seems like they do not have FIFO as you mention.
 

Iam using virtual distance measuring tape using gps with 8051
i need to read the data only latitude and longitude
iam getting so many other characters which i dont need on lcd

here is my code
#include <reg51.h> //Define 8051 Registers
#include <stdio.h>
#include <string.h> //Define I/O Functions
#define DATA P1 //Define DATA to Port1


#ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
/* is enabled */

//Define control pins

sbit RS = P3^5; //Register Select
sbit RW = P3^6; //LCD Read/Write
sbit lcd_e = P3^7; //LCD Enable
unsigned char check;unsigned char utc; char active; char latitude[];
char lat_hem; char longitude[]; char lon_hem;
unsigned char temp; int n=0;
unsigned char buf[50];code unsigned char temp1; int p=0;code unsigned char longit[50];unsigned char data2;


//----------------------------------
// LCD Functions
//----------------------------------
//void lcd_cmd(unsigned char);
//void lcd_display(unsigned char);

void DelayMs(int);


//----------------------------------
// LCD command Function
//----------------------------------
void lcd_cmd(unsigned char cmnd)
{
DATA = cmnd;
RS = 0;
RW = 0;
lcd_e = 1;
DelayMs(35);
lcd_e = 0;
}


//----------------------------------
// LCD Data Function
//----------------------------------
void lcd_display(unsigned char dat)
{
DATA = dat;
RS = 1;
RW = 0;
lcd_e = 1;
DelayMs(35);
lcd_e = 0;
}



//----------------------------------
// LCD Delay Function
//----------------------------------
void DelayMs(int k)
{
unsigned int a;
for(a=0;a<=k;a++);
}



//----------------------------------
// LCD Initialization
//----------------------------------
void lcd_init(void)
{
unsigned char i;
unsigned char j;
lcd_cmd(0x38); //2x16 Character 5x7 dot
DelayMs(15); //matrix LCD,8-bit format
lcd_cmd(0x0c); //Display On, cursor off
DelayMs(15);
lcd_cmd(0x06); //Shift Cursor to right
DelayMs(15);
lcd_cmd(0x01); //Clear display screen
DelayMs(15);


//-------------------------------------------
// First Line Message Display
//-------------------------------------------
lcd_cmd(0x80); //First Line Initialization
DelayMs(35);
i=0;
while(buf!='\0')
{
lcd_display(buf);
i++;
}
DelayMs(50);
//second line
/* lcd_cmd(0xc1);
DelayMs(35);
while(longit[j]!='\0')
{
lcd_display(longit[j]);
j++;
} */

while(1);
}



//----------------------------------
// LCD Main Program
//----------------------------------
void main(void)
{

while(1)
{
#ifndef MONITOR51
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0XFD; /* TH1: reload check for 1200 baud @ 16MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
#endif

check= scanf("%c",&check);
if(check='$')
{ check=scanf("%c",&check);
if(check='G')
{ check=scanf("%c",&check);
if(check='P')
{ check=scanf("%c",&check);
if(check='R')
{ check=scanf("%c",&check);
if(check='M') { check=scanf("%c",&check);
if(check='C') { check=scanf("%c",&check);
if(check=',')
{
do
{
scanf("%c", &temp );
}
while(temp!=',') ;
check=scanf("%c",&temp);
if(check='A') {
do{
scanf("%c", &temp); }
while(temp!=',');

do
{ scanf("%c", &temp);
sprintf(buf+n,"%c", temp); n=n+1; }
while(temp!=',');
do{
scanf("%c", &lat_hem); }
while(lat_hem!=',');
do
{ scanf("%c", &data2);
sprintf(buf+n,"%c",data2);n=n+1;
}
while(data2!=',');
}

} }}}}}


lcd_init(); //LCD Initialization
DelayMs(50);
}}}




please reply..........................
thank u
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top