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 support@ccsinfo.com

Flexible LCD driver
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

PostPosted: Fri Apr 06, 2007 6:10 pm     Reply with quote

hi pcm

i wonder if i can use PIN A4 and PIN A5 as independent input or output
i try but it not work independently
thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 07, 2007 11:15 am     Reply with quote

You didn't post the PIC that you're using. When you have a hardware-
specific question, you should post the PIC type.

On many PICs, the pin driver for Pin A4 is "open drain". It doesn't have
the ability to drive the pin to a high level. It can only drive it to a low
level. If you set the pin to be at a high level with the output_high()
function, the output will be "floating". You can fix this by adding an
external pull-up resistor to the pin. You can use 4.7K.

On some PICs, pin A5 is an "input only" pin. It doesn't have the
ability to drive the output in any way. So it can't be used with the
Flex LCD driver.
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

PostPosted: Sat Apr 07, 2007 11:49 pm     Reply with quote

i use 16f877a
applecon2000



Joined: 29 Jul 2007
Posts: 31
Location: UK

View user's profile Send private message Send e-mail MSN Messenger

ask for help
PostPosted: Tue Jul 31, 2007 8:26 pm     Reply with quote

Dear sir, can you explain the following code in LCD.C
"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]);

// If the R/W signal is not used, then
// the busy bit can't be polled. One of
// the init commands takes longer than
// the hard-coded delay of 60 us, so in
// that case, lets just do a 5 ms delay
// after all four of them.
#ifndef USE_LCD_RW
delay_ms(5);
#endif
}

}
"
i do not understand the meaning of "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]);
"
why we need to set those parameters for LCD initialization?
please explain the purpose for me
I do thank you for your reply.
_________________
Enjoy our EEE
applecon2000



Joined: 29 Jul 2007
Posts: 31
Location: UK

View user's profile Send private message Send e-mail MSN Messenger

sorry for my question
PostPosted: Tue Jul 31, 2007 8:38 pm     Reply with quote

for my question shown above:
Could u just explain the meaning of the code :for(i=0 ;i < 3; i++)
{
lcd_send_nibble(0x03);
delay_ms(5);
}

lcd_send_nibble(0x02);

......................................#
what's the purpose of first "for(i=0 ;i < 3; i++)" and the code of "lcd_send_nibble(0x02); "
thanks a lot and sorry about my previous problem
_________________
Enjoy our EEE
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 31, 2007 10:11 pm     Reply with quote

You need to use http://www.google.com to search for articles on
how to use an LCD.

For example, search using Google for:
Quote:
LCD commands

Then you get results such as this page:
http://www.geocities.com/dinceraydin/lcd/commands.htm

Also search with Google for:
Quote:
LCD initialize

Then you get this result:
http://www.myke.com/lcd.htm

Also look at the data sheet for the LCD controller.
http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

Please use http://www.google.com to find answers on all LCD questions.
pokiko



Joined: 27 Jul 2007
Posts: 33

View user's profile Send private message Send e-mail

PostPosted: Fri Aug 03, 2007 7:26 am     Reply with quote

Could you give an example for 4 bit LCD by using flexlcd driver and pic18f2520 for hd44780 16x2 LCD which will write to screen just "hello". The pin congiguration have to be as follows.

LCD PIC

D7 -- RB7
D6 -- RB6
D5 -- RB5
D4 -- RB4
E -- RB3
RS -- RB2

RW is grounded. PIC's RB0 and RB1 is used for another aim. crystal oscillator is 20 MHZ.

what kind of configuration i have to make in driver.
thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 03, 2007 12:07 pm     Reply with quote

At the start of the Flex_LCD.c file, edit the pin list so it looks like this:
Code:
#define LCD_DB4   PIN_B4
#define LCD_DB5   PIN_B5
#define LCD_DB6   PIN_B6
#define LCD_DB7   PIN_B7

#define LCD_E     PIN_B3
#define LCD_RS    PIN_B2


Because you have the R/W pin on the LCD connected to ground, you
need to comment out the following line in the Flex_LCD.c file, as shown:
Code:
//#define USE_RW_PIN   1


Here is a demo program to display "Hello World" on the LCD:
Code:

#include <18F2520.h>
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000) 

#include "Flex_LCD.c"
//=======================
void main()
{
lcd_init();

lcd_putc("Hello World");

while(1);
}
BrunoCF



Joined: 14 Aug 2007
Posts: 2
Location: SP - Brasil

View user's profile Send private message MSN Messenger

Thanks
PostPosted: Tue Aug 14, 2007 5:00 am     Reply with quote

Thank you for the code. Worked just fine for me.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 8:38 am     Reply with quote

I have purchased the PICDEM 2 PLus board and i am using the Flex_lcd driver for the lcd. However, i am finding that if i try to write more than 7 characters on a line, it locks up the PIC.
#include <18F4520.h>
#device adc=8
#include <stdio.h>
#include <math.h>



#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV25 //Brownout reset at 2.5V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES XINST //Extended set extension and Indexed Addressing mode enabled



#use delay(clock=4000000,RESTART_WDT)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#include <Flex_LCD>

void main()
{

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while (true)
{
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_C2);
delay_ms(1000);
output_high(PIN_B0);
output_high(PIN_B1);
output_high(PIN_B2);
output_high(PIN_B3);
//output_high(PIN_C2);
delay_ms(1000);
printf("Hello\n\r");
output_high(PIN_D7);
lcd_init();
printf(lcd_putc,"\fRawson\n");
printf(lcd_putc,"Accurat");
}
}
Does anyone have any idea what i am doing wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 9:07 am     Reply with quote

Quote:
#FUSES XINST //Extended set extension

This fuse setting will cause the program to run erratically.
Change it to NOXINST. Do this in all your programs for PICs that
have that fuse.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 12:12 pm     Reply with quote

Thanks for the input. Do you have any ideas on why i can only do 7 characters?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 12:40 pm     Reply with quote

1. The 'XINST' fuse could be the cause of it doing only seven characters.
Make sure you change it to 'NOXINST' in all your programs.
It's essential.

2. Post the list of #define statements that show the connections
between the LCD and the PIC. These #define statements are at
the start of the Flex_lcd.c driver, and must match the connections
on your PIC board.

3. Your test program is too complicated. Try a very simple program.
Example:
Code:

#include <18F4520.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#include "flex_lcd.c"
   
//==========================
void main()
{
lcd_init();

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

while(1);
}
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 3:17 pm     Reply with quote

I changed the setting to NOXINST and it still performed the same. Here are my defines from the flex_lcd file.

// 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_D0
#define LCD_DB5 PIN_D1
#define LCD_DB6 PIN_D2
#define LCD_DB7 PIN_D3

#define LCD_E PIN_D6
#define LCD_RS PIN_D4
#define LCD_RW PIN_D5

// 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

//========================================

#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 17, 2007 3:52 pm     Reply with quote

Based on those pin numbers, you are apparently using the new "Rohs
update" version of the PicDem2-Plus board.

That version of the board can be identified by a surface-mount pad
pattern at the bottom of the proto-typing area on the board. The older
version of the board doesn't have that surface-mount area on it.

If you have the new Rohs version of the board you need to use the
test program shown below. Notice how it adds a #define statement
for the LCD power pin, and it adds two new lines at the start of main().
Those lines are essential for the new Rohs version of the PicDem2-Plus.

Here are the pin assignments that you must set at the top of the Flex
driver. Also, for the "Rohs" PicDem2-Plus board, you must comment
out the "#define USE_LCD_RW 1" line, as shown below.
Code:

// These are the pin assignments used for the "Rohs"
// PicDem2-Plus:
#define LCD_DB4   PIN_D0
#define LCD_DB5   PIN_D1
#define LCD_DB6   PIN_D2
#define LCD_DB7   PIN_D3

#define LCD_E     PIN_D6
#define LCD_RS    PIN_D4
#define LCD_RW    PIN_D5

// The following line must be commented out for
// the "Rohs" board.

// #define USE_LCD_RW   1   
     


Test program for "Rohs" version of PicDem2-Plus board:
Code:

#include <18F4520.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#define LCD_POWER  PIN_D7

#include "Flex_LCD.c"

//============================
void main()
{
output_high(LCD_POWER);  // Turn on power to LCD
output_low(LCD_RW);      // Set R/W pin on LCD to a low level

lcd_init();              // Initialize the LCD

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

while(1);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 3 of 7

 
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