lcd_hd44780_8
LCD library for HD44780 compatible LCDs, with 8 bits wide datatransfer
|
Author
|
Rob Hamerling, Copyright (c) 2008..2009, all rights reserved.
|
|
Adapted-by
|
Eur van Andel, Joep Suijs (refactoring)
|
|
Compiler
|
>=2.4g
|
Description
Port interface for HD44780 compatible alphanumeric LCD screens.
Uses 8 bit wide datapath + 2 handshake lines (total 10 PIC pins).
Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en'
- 1 complete port for data: 'lcd_dataport'
or
- 2 pins for handshake: 'lcd_rs' and 'lcd_en'
- 8 lines for data: 'lcd_d0' .. 'lcd_d7'
note: a 'port nibble' - the lower or higher 4 bits of a port - give
faster and more compact code then random selected data lines.
.
Directions for use of this library in application programs
(in this sequence):
1. Declare the following constants:
const byte LCD_ROWS = 2 -- 1, 2 or 4 lines
const byte LCD_CHARS = 16 -- 8, 16 or 20 chars per line
and variables (aliases):
var bit lcd_rs is pin_D2 -- cmd/data select
var bit lcd_en is pin_D3 -- trigger
and variables (aliases):
var byte lcd_dataport is portF -- 8 data pins
or
var byte lcd_dataport_low is portD_high -- 4 low order data pins
var byte lcd_dataport_high is portC_high -- 4 high order data pins
or
var bit lcd_d0 is pin_D0 -- databit d0 pin
var bit lcd_d1 is pin_D1 -- databit d1 pin
var bit lcd_d2 is pin_C6 -- databit d2 pin
var bit lcd_d3 is pin_C7 -- databit d3 pin
var bit lcd_d4 is pin_B0 -- databit d4 pin
var bit lcd_d5 is pin_B1 -- databit d5 pin
var bit lcd_d6 is pin_C0 -- databit d6 pin
var bit lcd_d7 is pin_C2 -- databit d7 pin
.
2. Set the chosen LCD handshake pins to output:
pin_D2_direction = output
pin_D3_direction = output
and the data port to output:
portF_direction = ALL_OUTPUT
or 2 half data ports to output:
portD_high_direction = ALL_OUTPUT
portC_high_direction = ALL_OUTPUT
or 8 individual pins to outout
pin_D0_direction = output -- set data pin as output
pin_D1_direction = output -- set data pin as output
pin_C6_direction = output -- set data pin as output
pin_C7_direction = output -- set data pin as output
pin_B0_direction = output -- set data pin as output
pin_B1_direction = output -- set data pin as output
pin_C0_direction = output -- set data pin as output
pin_C2_direction = output -- set data pin as output
.
3. Include this library.
.
4. Call lcd_init() to initialize the lcd controller.
.
Above is an example for a 2x16 LCD.
.
See hd_44780_common for the LCD API.
Dependencies
Private
Private
Here are the list of samples which use this library: