LCD_IO 4

Using connection mode 4:

To use connection mode 4 the R/W, RS, Enable control lines and the highest 4 data lines (DB4 through DB7) must be connected to the microcontroller.

Relevant Constants:

Specific constants are used to control settings for the Liquid Crystal Display routines included with GCBASIC. To set these constants the main program should specific constants to support the connection mode using #define. Constants required for connection mode 4.

Constants are required for 4-bit mode as follows.

Constant Name Controls Default Value

LCD_SPEED

FAST, MEDIUM or SLOW.

MEDIUM

LCD_IO

Must be 4

4

LCD_RS

Specifies the output pin that is connected to Register Select on the LCD.

Must be defined as port.bit

LCD_RW

Specifies the output pin that is connected to Read/Write on the LCD. The R/W pin can be disabled*.

Must be defined as port.bit (unless R/W is disabled)

LCD_Enable

Specifies the output pin that is connected to Read/Write on the LCD.

Must be defined as port.bit

LCD_DB4

Output pin used to interface with bit 4 of the LCD data bus

Must be defined as port.bit

LCD_DB5

Output pin used to interface with bit 5 of the LCD data bus

Must be defined as port.bit

LCD_DB6

Output pin used to interface with bit 6 of the LCD data bus

Must be defined as port.bit

LCD_DB7

Output pin used to interface with bit 7 of the LCD data bus

Must be defined as port.bit

     

LCD_VFD_DELAY

Specifies a delay between transmission of data nibbles to LCD or VFD.

Usage must include number value and unit of time.

#DEFINE LCD_VFD_DELAY 1 ms

Only applicable when using LCD_IO 4

None.

LCD_OCULAR_OM1614

Specifies OCULAR OM1614 suppport. This changes the intialisation routine to a specific routine for the OCULAR devices.

To specify explicit OCULAR_OM1614 support #DEFINE LCD_OCULAR_OM1614

The OCULAR devices requires LCD_RW

The R/W pin can be disabled by setting the LCD_NO_RW constant. If this is done, there is no need for the R/W to be connected to the chip, and no need for the LCD_RW constant to be set. Ensure that the R/W line on the LCD is connected to ground if not used.

Example:

    #chip 16F877A, 20

    ' Connection mode 4: a 4-bit parallel connection using the LCD's
    ' upper four data lines (DB4-DB7), plus RS and Enable. R/W is disabled
    ' here (LCD_NO_RW), so the LCD's R/W pin must be tied to ground.
    #define LCD_IO 4
    #define LCD_NO_RW

    #define LCD_RS      PORTA.7
    #define LCD_Enable  PORTA.6
    #define LCD_DB4     PORTB.4
    #define LCD_DB5     PORTB.5
    #define LCD_DB6     PORTB.6
    #define LCD_DB7     PORTB.7

    CLS

    Print "Hello World."          ' <<< the print instruction this page documents

    End

Key line: Print "Hello World." — each character is written as two 4-bit nibbles over LCD_DB4-LCD_DB7, strobed by LCD_Enable, exactly as the physical LCD’s HD44780-style controller expects in 4-bit mode.

Also see further code examples at Four Wire LCD Solutions.

See the separate sections of the Help file for the specifics of each Connection Mode.

See Also:

  • LCD_IO 0 — single subroutine, software-driven mode
  • LCD_IO 1 — 1-wire, via a 74HC595 shift register
  • LCD_IO 2 — 2-wire shift register, deprecated
  • LCD_IO 2_74xx164 — 2-wire via 74HC164/74LS164, the preferred 2-wire method
  • LCD_IO 2_74xx174 — 2-wire via 74LS174, deprecated
  • LCD_IO 3 — 3-wire shift register with an added Enable line
  • LCD_IO 8 — 8-bit parallel connection
  • LCD_IO 10 — I2C via a PCF8574/PCF8574A I/O expander
  • LCD_IO 12 — I2C via a Ywmjkdz-layout adapter
  • LCD_IO 14 — SPI expander
  • LCD_IO 16 — PIC16LF72 SPI expander
  • LCD_IO 107 — K107 serial adapter