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

lcd 2x16 with flex_lcd.c

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



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

lcd 2x16 with flex_lcd.c
PostPosted: Wed Mar 17, 2010 11:51 am     Reply with quote

hi

I try use this driver "flex_lcd.c" but when I write on my program lcd_init(); program stop.

My code:
Code:

#include <18F252.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,STVREN
#use delay(clock=20000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#build(reset=0x200)
#build(interrupt=0x208)
#org 0x0000,0x01ff
void bootloader() {
#asm
nop
#endasm
} // Reserve space for the bootloader

// Libraries
#include <flex_lcd.c>

void main()
{
lcd_init(); // Always call this first.

lcd_putc("\fHello\n");
lcd_putc("Line Number 2");

while (TRUE)
  {
//###### flash led for test #######

   output_high(PIN_C3);
   delay_ms(500);
   output_low(PIN_C3);
   delay_ms(500);
  }
}


flex_lcd.c
Code:

// flex_lcd.c

// These pins are for the Microchip PicDem2-Plus board,
// which is what I used to test the driver. Change these
// pins to fit your own board.

#define LCD_DB4 PIN_B7
#define LCD_DB5 PIN_B6
#define LCD_DB6 PIN_B5
#define LCD_DB7 PIN_B4

#define LCD_E PIN_C0
#define LCD_RS PIN_C1
#define LCD_RW PIN_C2

// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.

#define USE_LCD_RW 1


PS: if I comment lcd_init(); my LED flash if I not comment it don't flash.
Someone can help me?

Best regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 12:37 pm     Reply with quote

Quote:

#define LCD_DB4 PIN_B7
#define LCD_DB5 PIN_B6

Pins B6 and B7 are used by the ICD debugger (or programmer).
Run the program in standalone mode (not with debugger), and
disconnect the ICD from the board. Then it should run OK.
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 12:48 pm     Reply with quote

in my case I don't use this pins for anything... I mount my circuit on bread-board.

and if I use the default LCD.C or LCD420.C I have the same problem, and I don't know why...

what you suggest?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 12:54 pm     Reply with quote

Check the connections between the PIC and the LCD.

See the schematics in this post for the connections:
http://www.ccsinfo.com/forum/viewtopic.php?t=30026&start=5
filjoa



Joined: 04 May 2008
Posts: 260

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 1:05 pm     Reply with quote

but problem stay on program or on compiler... because my program stop if I write "lcd_init();" and not have LCD on circuit

my last test I only have one led on PIN_B7 and program stop.

PS:my ccs version is 4.104

best regards
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 1:10 pm     Reply with quote

You must have LCD present when calling LCD_init(); function, if not the program will hang there.

That is because this function expects answer from LCD unit when is initialised.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 17, 2010 1:11 pm     Reply with quote

Quote:

but problem stay on program or on compiler...
because my program stop if I write "lcd_init();" and not have LCD on circuit

Wrong. The Flex lcd driver reads the Busy bit from the LCD in
this routine:
Quote:

void lcd_send_byte(int8 address, int8 n)
{
output_low(LCD_RS);

#ifdef USE_RW_PIN
while(bit_test(lcd_read_byte(),7)) ;
#else
delay_us(60);
#endif

If there is no LCD connected, or if the connections are not correct,
the Flex driver will hang in the while() loop forever.

Check your connections to the LCD.
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