![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
UART and GPS |
Posted: Sun Dec 07, 2008 2:23 pm |
|
|
Hi, trying to display GPS data on an LCD that start with"$P" or "$G" and all others discarded. For some reason I am still displaying other data such as"$F" and "$ ". GPS is working fine and LCD working fine , but somewhere in the code I am going wrong! Help appreciated, Cheers.
Code: |
#include <18f452.h>
#include <string.h>
#fuses HS,NOLVP,NOWDT
#use delay (clock=20000000)
//
#use rs232 (baud=4800, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8, ERRORS)
//
//Misc defines
#define GREEN_LED PIN_E2
//LCD defines
#define D0_LCD PIN_B0
#define D1_LCD PIN_B1
#define D2_LCD PIN_B2
#define D3_LCD PIN_B3
#define D4_LCD PIN_B4
#define D5_LCD PIN_B5
#define D6_LCD PIN_B6
#define D7_LCD PIN_B7
#define EN_LCD PIN_D6
#define RS_LCD PIN_D7
#define RW_LCD PIN_D5
#define TOP_LINE 0x80
#define BOTT_LINE 0xC0
#define CLEAR_DISP 0x01
#define RETURN_HOME 0x02
void LCD_INIT (int x);
void DATA_MANIP (unsigned int x);
void LCD_INIT (int x){
..........
}
void DATA_MANIP (unsigned int x){
output_high (EN_LCD);
output_bit ( D0_LCD, x & 0x01 );
output_bit ( D1_LCD, x & 0x02 );
output_bit ( D2_LCD, x & 0x04 );
output_bit ( D3_LCD, x & 0x08 );
output_bit ( D4_LCD, x & 0x10 );
output_bit ( D5_LCD, x & 0x20 );
output_bit ( D6_LCD, x & 0x40 );
output_bit ( D7_LCD, x & 0x80 );
output_low (EN_LCD);
}
//
void main (void){
char r;
int x, y;
LCD_INIT (0); //
x=0;
y=0;
while(TRUE){
r=getc();
if ((x>0)&&(x<15)){ //Display charactors to end of lcd display
x++;
DATA_MANIP (r);
} else if (x==15){ //End of display line
delay_ms(2000);
x=0;
if(y==0){
LCD_INIT (2); //Bottom Line
y=1;
} else{
LCD_INIT (1); //Top Line
y=0;
}
} else if ((r=='$')&&(x==0)){ //start of new gps data
r=getc();
if (r=='G') {
DATA_MANIP ('$');
DATA_MANIP ('G');
x++;
}
if (r=='P'){
DATA_MANIP ('$');
DATA_MANIP ('P');
x++;
}
} else{
x=0;
}
}
}
|
Last edited by uni_student on Sun Dec 07, 2008 2:49 pm; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 07, 2008 2:38 pm |
|
|
Post the manufacturer and part number of your LCD. |
|
![](templates/subSilver/images/spacer.gif) |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
|
Posted: Sun Dec 07, 2008 2:48 pm |
|
|
Quote: |
Post the manufacturer and part number of your LCD.
|
Unsure of manufacturer of LCD (will check when home from work), but has Hitachi HD44780 driver in it. 16x2 LCD display, got it from futurlec.com. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Dec 07, 2008 2:51 pm |
|
|
My suggestion is to use the flex LCD driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
Then you can call lcd_putc() to display a character, or use printf
to display a string (and re-direct the output of printf to lcd_putc).
It's much easier than your method. |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Dec 07, 2008 4:28 pm |
|
|
Although the code has long-winded actions, as the port B single bit output, it most likely doesn't keep the required timing according to HD44780 spec. With a parallel interface, it's easy to check the busy flag before writing to the display.
The single bit output can be replaced by a simple output_b(x); |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|