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, KBD, 628

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







LCD, KBD, 628
PostPosted: Fri Oct 27, 2006 5:56 am     Reply with quote

Hi, I am trying to get an LCD and keypad to work on port B on a 16F628 and it is driving me nuts!! The LCD is Hitachi compatible and in 4 bit mode.
I am using FlexLCD with assignments as follows:
#define LCD_DB4 PIN_B3
#define LCD_DB5 PIN_B4
#define LCD_DB6 PIN_B5
#define LCD_DB7 PIN_B6
#define LCD_E PIN_B2
#define LCD_RS PIN_B1
I have not used B7 as I want to use this for controlling the backlight
The R/W pin on the LCD is grounded.
The display works fine.
The keypad is a 3 col, 4 row (RS 115-6031) Cols are on B6, B5, B4 and rows on B3, B2,B1,B0
port_b pullups on
Using Flex_kbd with:
#define col0 PIN_B4
#define col1 PIN_B5
#define col2 PIN_B6
#define row0 PIN_B0
#define row1 PIN_B1
#define row2 PIN_B2
#define row3 PIN_B3
Row 4,5,6 doesn't work at all. Other keys produce multiple characters, usually including the key value. The longer it is on, the worse it gets. I have messed with the debounce factor without much luck.
Why is it that in both the original CCS kbd driver and the Flex driver that kbd_init is an empty function and yet the header says it must be called first?
I am NOT using ICSP
In absloute frustration....
Brian
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 27, 2006 11:24 am     Reply with quote

This thread explains how to use the CCS drivers (not Flex drivers)
to get the keypad and the LCD to work on the same port.
http://www.ccsinfo.com/forum/viewtopic.php?t=26229

With regard to the Flex drivers, I wrote the two LCD drivers (for the
16x2 and the 20x4 LCDs).

Ahmed wrote the keypad driver.

There is no guarantee of compatibility between the LCD and keypad
drivers. Ahmed is apparently no longer an active member of the forum.
I don't really want to spend a lot of time making his driver work with
my drivers.

My suggestion is to do it way that's described in the link above.
BLL
Guest







Message
PostPosted: Sat Oct 28, 2006 5:48 am     Reply with quote

Hi, Thanks for reply although it doesn't help much. I have been unable to get the provided lcd and kbd routines to work. I have now moved enable and RS to port A, but still it is useless. Wiring is all correct, more than 1 chip tried. I am not therefore impressed with CCS routines! I have looked at the link you gave but except for resistors in series with keypad connections, it doesn't help!

It seems amazing that with an expensive C compiler, it isn't even possible to get a kbd and LCD to work!

Very frustrated and fed up!!

Brian
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 28, 2006 11:12 am     Reply with quote

Quote:
I have now moved enable and RS to port A, but still it is useless.

That statement means you are still trying to use the "flex" drivers that
you found in the forum's Code Library. I know this, because the CCS
lcd driver, LCD.C, doesn't have the ability to put some pins on different
ports. In my post, I suggested that you don't use the "flex" drivers.

Instead, use the CCS drivers, which are on your hard disk:

c:\Program Files\Picc\Drivers\LCD.c
c:\Program Files\Picc\Drivers\KBD.c

Also use the CCS example file, which uses the drivers listed above:

c:\Program Files\Picc\Examples\EX_LCDKB.c

The link that I gave explains how to use these drivers and example
file on a PicDem2-Plus board (from Microchip).
http://www.ccsinfo.com/forum/viewtopic.php?t=26229

What demo board do you have ? Or are you building your own board ?

It's certainly possible to make it work. Here's an example at the
Blitzlogic website, and they use the same files listed above.
http://www.blitzlogic.com/lcd.htm

One very important aspect is the connections to the keypad.
Keypads are not all the same. The pins for the columns and rows
are often different between brands of keypads.
BLL
Guest







LCD, KBD
PostPosted: Sat Oct 28, 2006 1:40 pm     Reply with quote

Hi,
I tried the CCS LCD and KBD files and still no luck. Something strange is happening! I have also tried using an 876 40pin. I thought I could put the LCD on portC (doesn't have a portD in the 40pin version) and the keypad on portB. So far, I can't get the LCD to do anything on portC - I have modified lcd.c for portC.
I could not believe it could be so difficult to get a keypad and an LCD to work on a pic!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 28, 2006 3:34 pm     Reply with quote

The 16F876 is 28 pins.

My advice is to start with little steps.

1. First make a program to blink an LED. Use an LED with a series
resistor (330 ohms is OK), attached to a pin. Turn it on and off at 500 ms
intervals.

2. Next, attach an LCD to the PIC. Use the LCD driver, and write a
program to display "Hello World" on the LCD. The LCD will use 6 or 7
i/o pins. (Remove the LED from the previous test).

3. Next, connect a keypad to a different port. This will use 7 or 8 i/o pins.
Get the keypad and the LCD working together. Use the programs I
suggested: LCD.c, KBD.c, and EX_LCDKB.c.

4. Finally, move the LCD or Keypad so that they're both running from
the same port.
BLL
Guest







628, LCD
PostPosted: Sat Oct 28, 2006 6:50 pm     Reply with quote

Hi, Thanks for your prompt replies. I think my brain's getting addled! I looked at that schematic you gave me the link to and decided to start over on a new plugboard! I noticed that he had the LCD RW line connected twice! I massaged kbd.c for my keypad, set the kbd delay to 0, port_b_pullups on and bingo, it works at last!! Now I just need to add a DS1302 to portA and I'm there!
Why it didn't work on the other prototype, I just don't know.
Thanks again for your help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 28, 2006 9:41 pm     Reply with quote

You're right about the R/W line in his schematic. I didn't notice that.
The schematic has been shrunken down and it's kind of hard to read.
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