CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

flexlcd issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

flexlcd issue
PostPosted: Thu Apr 30, 2009 5:41 pm     Reply with quote

I'm trying to use flex_lcd.c
I modified it to match my pinout
Code:
#define LCD_DB4   PIN_C1
#define LCD_DB5   PIN_D1
#define LCD_DB6   PIN_C2
#define LCD_DB7   PIN_C0

#define LCD_E     PIN_D0
#define LCD_RS    PIN_C5
#define LCD_RW    PIN_D2

Then in my main program I have

Code:

Printf("Starting up\r\n");
lcd_init();  // Always call this first.
Printf("LCD started\r\n");

I get the first print statement, but not the 2nd. The pic is just locked up. I looked at lcd_init and don't see where it could be waiting on anything.
Any thoughts on what would make this hang?
Code:

void lcd_init(void)
{
int8 i;
output_low(LCD_RS);
#ifdef USE_LCD_RW
output_low(LCD_RW);
#endif

output_low(LCD_E);
delay_ms(15);

for(i=0 ;i < 3; i++)
   {
    lcd_send_nibble(0x03);
    delay_ms(5);
   }

lcd_send_nibble(0x02);

for(i=0; i < sizeof(LCD_INIT_STRING); i++)
   {
    lcd_send_byte(0, LCD_INIT_STRING[i]);
   
    #ifndef USE_LCD_RW
    delay_ms(5);
    #endif
   }

_________________
Ringo Davis
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Thu Apr 30, 2009 5:50 pm     Reply with quote

oh yeah, It is an 18f4550 and pch 4.086
_________________
Ringo Davis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 30, 2009 5:57 pm     Reply with quote

What about this line ? Is it uncommented ? It should look like this:
Code:
#define USE_RW_PIN   1     

In other words, it's in effect.


Also, post the manufacturer and part number of your LCD.
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Thu Apr 30, 2009 6:07 pm     Reply with quote

yes it is uncommented. I have it wired up.
I just commented it out and it no longer hangs, but I'm getting nothing from the LCD.
THe LCD does not have a part number, but it has the standard HD4780 chip on it and a 16 pin header.
_________________
Ringo Davis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 30, 2009 6:14 pm     Reply with quote

If it doesn't hang when that line is commented, it means there's a
problem with reading the Busy bit, or just in reading the LCD.

Try this:
Comment that line, and tie the R/W pin on the LCD to ground.
That pin should not be connected to the PIC anymore.
This will test if the LCD can operate OK with a 6-pin interface.
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Thu Apr 30, 2009 6:21 pm     Reply with quote

OK, did that now I just get black boxes on the screen. Tried the contrast, that does not help.

By the way I know the LCD is good. I built up a board with a small pic on it and attached an lcd. The board takes in serial text and displays it. I can plug this lcd into the board and it works. THe problem is I built this board 10 years ago and don't have the source for it anymore. At least it lets me test the LCD :-)
_________________
Ringo Davis
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 01, 2009 3:20 pm     Reply with quote

Quote:

It is an 18f4550.

#define LCD_DB4 PIN_C1
#define LCD_DB5 PIN_D1
#define LCD_DB6 PIN_C2
#define LCD_DB7 PIN_C0

#define LCD_E PIN_D0
#define LCD_RS PIN_C5
#define LCD_RW PIN_D2

Pin C5 can't be used on this PIC. It's either a USB pin or it's an input-only
pin. The LCD driver requires an output pin. You need to choose another pin.
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Sun May 03, 2009 10:35 am     Reply with quote

Thanks, I missed that. I was originally going to use a 452 which does not have that restriction, but I grabbed the other pic by mistake and had soldered it before I noticed.

Anyway, I can now send data to the LCD as long as it is not a variable. How do I send variable info.
For example, I tried this;
sprintf(alt,"\fAltitude: %6.2f\n",pressure_feet);
printf("%s",alt);
lcd_putc(alt);

but I get garbage.
something like
lcd_putc("\faltitude is 500\n");
works fine.
The printf of alt looks ok too.

I'm assuming the probelm is that sprintf "The output string will be terminated with a null."

If that is the problem, how do I fix it? I could put an extra case statement in flex_lcd.c in lcd_putc, but how do I specify a null?

Thanks
Ringo
_________________
Ringo Davis
Ringo42



Joined: 07 May 2004
Posts: 263

View user's profile Send private message

PostPosted: Sun May 03, 2009 10:46 am     Reply with quote

Nevermind I found it.
printf(lcd_putc"\fAlt: %6.2f\n",pressure_feet);


RIngo
_________________
Ringo Davis
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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