- This topic has 5 replies, 2 voices, and was last updated 12 years, 6 months ago by AJISH ALFRED.
-
AuthorPosts
-
July 25, 2012 at 8:44 am #4778sdfsdfsfParticipant
I follow the below website to do.
But, the program did not work.
The following problem will appear.
Have anyone can help me to fix these problem???
July 25, 2012 at 8:46 am #8326sdfsdfsfParticipantThe code.
// Program to Interface GPS with PIC18F4550 Microcontroller
#define FREQ 12000000
#define baud 4800
#define spbrg_value (((FREQ/64)/baud)-1)
#define rs LATA.F0
#define rw LATA.F1
#define en LATA.F2
#define lcdport LATBunsigned char rx_data();
void lcd_ini();
void lcdcmd(unsigned char);
void lcddata(unsigned char);unsigned char longi_data[12];
unsigned char lati_data[12];
unsigned char data,value=0;
unsigned int i=0,pos;void main()
{
TRISB=0; // Set Port B as output port
LATB=0;
TRISA=0;
LATA=0;
SPBRG=spbrg_value; // Fill SPBRG register to set the baud rate
RCSTA.SPEN=1; // To activate serial port (Tx and Rx pins)
RCSTA.CREN=1; // To enable continuous reception
lcd_ini();
while(1)
{
data=rx_data(); // Check the string ‘$GPGGA,’
if(data==’$’)
{
data=rx_data();
if(data==’G’)
{
data=rx_data();
if(data==’P’);
{
data=rx_data();
if(data==’G’);
{
data=rx_data();
if(data==’G’)
{
data=rx_data();
if(data==’A’)
{
data=rx_data();
if(data==’,’)
{
data=rx_data();
while(data!=’,’)
data=rx_data();
for(i=0;data!=’N’;i++)
data=rx_data();
lati_data=data; // Store the Latitude data
}
data=rx_data();
if(data==’,’)
{
for(i=0;data!=’E’;i++)
{
data=rx_data();
longi_data=data; // Store the Longitude data
}
}
i=0;
lcdcmd(0x80);
while(i<11)
{
lcddata(lati_data); // Print the Latitude data
i++;
}
i=0;
lcdcmd(0xC0);
while(i<12)
{
lcddata(longi_data); // Print the Longitude data
i++;
}
}
}
}
}
}
}
}
Delay_ms(1000);
for(i=0;i<12;i++)
{
data=0;
lati_data=0;
longi_data=0;
}
}
}unsigned char rx_data(void)
{
while(PIR1.RCIF==0); // Wait until RCIF gets low
return RCREG; // Store data in Reception register
}void lcd_ini()
{
lcdcmd(0x38); // Configure the LCD in 8-bit mode, 2 line and 5×7 font
lcdcmd(0x0C); // Display On and Cursor Off
lcdcmd(0x01); // Clear display screen
lcdcmd(0x06); // Increment cursor
lcdcmd(0x80); // Set cursor position to 1st line, 1st column
}void lcdcmd(unsigned char cmdout)
{
lcdport=cmdout; //Send command to lcdport=PORTB
rs=0;
rw=0;
en=1;
Delay_ms(10);
en=0;
}void lcddata(unsigned char dataout)
{
lcdport=dataout; //Send data to lcdport=PORTB
rs=1;
rw=0;
en=1;
Delay_ms(10);
en=0;
}July 27, 2012 at 2:08 pm #8342AJISH ALFREDParticipantHi,
Both the images are not legible. Better you post the link and describe the problem which you face.
July 28, 2012 at 7:07 am #8349sdfsdfsfParticipantThe 1602LCD will show this.
July 28, 2012 at 5:26 pm #8350AJISH ALFREDParticipantLCD not initialized!
Check your circuit connections.
Still not working, then modify the lcdcmd() function as shown below.
void lcdcmd(unsigned char cmdout)
{
lcdport=cmdout; //Send command to lcdport=PORTB
rs=0;
rw=0;Delay_ms(10); //add a delay here also
en=1;
Delay_ms(10);
en=0;
}Also make sure that the PORTB, rs, rw, en are properly set as output, and the function Delay_ms() is generating millisecond delays as much as the parameter given in the function call.
July 28, 2012 at 5:32 pm #8351AJISH ALFREDParticipantStill not working, then modify the lcdcmd() function again as shown below.
void lcdcmd(unsigned char cmdout)
{
lcdport=cmdout; //Send command to lcdport=PORTB
rs=0;
rw=0;Delay_ms(10); //add a delay here also
en=1;
Delay_ms(10);
en=0;Delay_ms(10); //add a delay here also
}Make sure that you are using the same kind of lcd module.
All you need is to get rid off that black boxes from lcd.
Still there is black boxes, then there is some mistake in your hardware.
-
AuthorPosts
- You must be logged in to reply to this topic.