PDA

View Full Version : LCD using 4 data lines, Lab X1



queenidog
- 20th January 2013, 21:04
I'm running a LabX1 with PIC 16F887. The schematic shows 8 data lines connected to port D of the MCU and the sample routines I have been using have the following defines:

DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1

The PBPro3 manual has an example with an LCD using only 4 bits D4-D7 using the "default values" of DEFINE LCD_DBIT 0 with the comment 'Set starting data bit (0 or 4) if 4-bit bus.

Q.1 So I'm confused. It appears if you use 8 lines (LabX1) you DEFINE LCD_DBIT 4 but if you only have 4 lines (example in book) you DEFINE LCD_DBIT 0. Isn't this backwards?

I want to use an LCD with a 16F88 and I may not have enough ports to use 8 data lines.

Q.2 The PBPro3 manual also has a define for LCD bus size called "LCD_BITS" which should be set to 4 or 8 depending on the # of bits used and for the book example is set "correctly" to 4. This DEFINE is not in the LabX1 routines. Does it default to 8 bits?

queenidog
- 20th January 2013, 23:10
I think I answered my own question....
The LabX1, despite showing all 8 data lines connected to the LCD, is operating in 4 bit mode. (I can tell by the simultaneous connected LEDs flashing). Thus the DEFINE should be LCD_DBIT 4 (start with 4th bit). The default in PBP3 for LCD_bits is 4 and since this is not defined explicitly in the DEFINES in the program (above) this is what it defaults to.

Still have a question about the schematic showing 8 lines connected and when I change the DEFINEs to reflect 8 lines, the display does not work (random flashing characters).