View previous topic :: View next topic |
Author |
Message |
filjoa
Joined: 04 May 2008 Posts: 260
|
lcd 2x16 with flex_lcd.c |
Posted: Wed Mar 17, 2010 11:51 am |
|
|
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
|
|
Posted: Wed Mar 17, 2010 12:37 pm |
|
|
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
|
|
Posted: Wed Mar 17, 2010 12:48 pm |
|
|
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
|
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Wed Mar 17, 2010 1:05 pm |
|
|
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
|
|
Posted: Wed Mar 17, 2010 1:10 pm |
|
|
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
|
|
Posted: Wed Mar 17, 2010 1:11 pm |
|
|
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. |
|
|
|