Introduction:
The LCD routines in this section allow GCBASIC programs to control an alphanumeric Liquid Crystal Displays based on the HD44780 IC. This covers most 16 x 1, 16 x 2, 20 x 4 and 40 x 4 LCD displays.
The GCBASIC methods allow the displays to be connected to the microcontroller
Connection Modes:
The table below shows the connection modes. These modes support the connection to the LCD using differing methods.
Connection Mode | Required Connections |
---|---|
0 |
No configuration is required directly by this method. The LCD routines
must be provided with other subroutines which will handle the
communication. This is useful for communicating with LCDs connected
through RS232 or I2C.
|
1 |
Uses a combined data and clock line. This mode is used when the LCD is connected through a
shift register 74HC595, as detailed at here.
|
2 |
Uses separated Data and Clock lines. This mode is used when the LCD is connected
through a 74LS174 shift register IC, as detailed at
here
|
3 |
|
4 |
|
8 |
|
10 |
The LCD is controlled via I2C. A type 10 LCD 12C adapter. Set |
12 |
The LCD is controlled via I2C. A type 12 LCD 12C adapter. Set |
107 |
The LCD is controlled via serial. Set |
Supported LCDs mapped to Connection Mode
The support of various types of LCD displays are shown in the following table.
Supported LCD Type number of characters x number of lines |
Connection Mode |
---|---|
16 x 1, 16 x 2, 20 x 2, 20 x 4 type LCD displays, |
0,1,2,4,8,10 and 12 |
40 x 4 LCD displays, |
4 |
16 x 1 LCD displays, with a non-standard/non-consective memory map. This LCD sub type is supported using a specific constant. Use Also known as 1601 type LCD displays. |
Supports any LCD_IO mode. |
Communication Performance
There may be a need to change the communication performance for a specific LCD as some LCD’s are slower to operate. GCBASIC supports change the communications speed.
To change the performance (communications speed) of the LCD use #DEFINE LCD_SPEED
. This method allows the timing to be optimised.
Example
#DEFINE LCD_SPEED FAST
Define | Performance Characteristics |
---|---|
|
|
If LCD_SPEED
is not defined, the speed defaults to SLOW
Using LCD_Speed OPTIMAL
.
Note
OPTIMAL
disables fixed delays and allows the LCD operate as fast as it can. In this mode, The the busy flag is polled before each
byte is sent to the HD44780 controller. This not only optimizes speed, but also assures that data is not sent to the diplay
controler until it is ready to receive the data.
With most displays this equates to a speed of about 30,000 characters per second. For comparision about 10 times faster than I2C using a PC8574 Expander (See LCD_IO 10 or See LCD_IO 112)
OPTIMAL
is only supported in LCD_IO 4,8 and only when LCD_NO_RW is not defined (RW Mode). When #DEFINE LCD_NO_RW
is defined, reading data from the HD44780 is not possible since this disables Read Mode on the controller. In this case
busy flag checking is not available and the GET subroutine is not avaiable.
In order to enable busy flag checking, and, therefore to use the GET
command the following criteria must be true.
- LCD I/O Mode must be either 4-wire or 8-wire
#DEFINE LCD_NO_RW
is not defined- An I\O pin is connected between the microcontroller and the RW connection on the LCD Display
'DEFINE LCD_RW port.pin
is defined in the GCBASIC source code
Example:
#DEFINE LCD_IO 4 #DEFINE LCD_SPEED OPTIMAL #DEFINE LCD_DB7 PORTB.5 #DEFINE LCD_DB6 PORTB.4 #DEFINE LCD_DB5 PORTB.3 #DEFINE LCD_DB4 PORTB.2 #DEFINE LCD_RW PORTA.3 'Must be defined for RW Mode #DEFINE LCD_RS PORTA.2 #DEFINE LCD_ENABLE PORTA.1
Changing the LCD Width
To change the LCD width characteristics use #define LCD_WIDTH
See the separate sections of the Help file for the specifics of each Connection Mode.
For more help, see LCD_IO 0, LCD_IO 1, LCD_IO 2, LCD_IO 3, LCD_IO_2 74xx164, LCD_IO_2 74xx174, LCD_IO 4, LCD_IO 8, LCD_IO 10 or LCD_IO 12
and,