News:

;) This forum is the property of Proton software developers

Main Menu

2-Wire LCD Controller

Started by GDeSantis, May 02, 2024, 08:13 PM

Previous topic - Next topic

GDeSantis

Per the Positron 8-Bit PIC MCU manual, the Print command is applicable for sending text to an LCD module using a Hitachi HD44780 compatible controller.  Furthermore, the LCD may be connected and operated in either the 4 or 8-bit modes assuming the MCU port pins are connected per the appropriate Print Declares.

More recently, Les make an excellent posting that described the program and circuitry associated with a one-wire LCD controller.

While I've successfully used both approaches, I now have an application that requires a 2-wire LCD controller based on the circuit noted in the attached file.

Although I've written a 2-wire controller Positron program that works; unfortunately it does not use the Alphanumeric (Hitachi HD44780) LCD Print Declares which is a big disadvantage.

Without creating extra work for any forum participant, can anyone suggest an easy way to address this issue?

top204

#1
Over the years, I've made Declares create either internal alias' or internal constants depending on their purpose, and these can be used within a user's program.

They are created for the purpose of my testing and verifying, but they can be useful to a user. However, because they are not part of the official compiler language, they are not in the manual. I may create an advanced section in the manual for some of the compiler's secrets. :-)

For example, the LCD declares will create several alias names relating to the Ports and Port Pins used, and constants for the pin values and timings and types etc...

So for a set of LCD declares such as:

    Declare LCD_Data0_Pin = PORTB.0
    Declare LCD_Data1_Pin = PORTB.1
    Declare LCD_Data2_Pin = PORTB.2
    Declare LCD_Data3_Pin = PORTB.3
    Declare LCD_Data4_Pin = PORTB.4
    Declare LCD_Data5_Pin = PORTB.5
    Declare LCD_Data6_Pin = PORTB.6
    Declare LCD_Data7_Pin = PORTB.7
    Declare LCD_RSpin = PORTA.0
    Declare LCD_ENpin = PORTA.1
    Declare LCD_Interface = 4
    Declare LCD_Lines = 2
    Declare LCD_Type = Alphanumeric
    Declare LCD_CommandUs = 2000
    Declare LCD_DataUs = 50


The compiler will produce:

Alias' created from the declares:

__LCD_DATA0_PORT_PIN   
__LCD_DATA1_PORT_PIN
__LCD_DATA2_PORT_PIN
__LCD_DATA3_PORT_PIN
__LCD_DATA4_PORT_PIN        Port and Pin combinations. i.e. PORTB.0
__LCD_DATA5_PORT_PIN
__LCD_DATA6_PORT_PIN
__LCD_DATA7_PORT_PIN
__LCD_RSPIN_PORT_PIN
__LCD_ENPIN_PORT_PIN

__LCD_DATA0_PORT
__LCD_DATA1_PORT
__LCD_DATA2_PORT            Ports
__LCD_DATA3_PORT
__LCD_DATA4_PORT
__LCD_DATA5_PORT
__LCD_DATA6_PORT
__LCD_DATA7_PORT
__LCD_RSPORT
__LCD_ENPORT

Constants created from the declares:

__LCD_DATA0_PIN
__LCD_DATA1_PIN
__LCD_DATA2_PIN
__LCD_DATA3_PIN            Pin values
__LCD_DATA4_PIN
__LCD_DATA5_PIN
__LCD_DATA6_PIN
__LCD_DATA7_PIN
__LCD_RSPIN
__LCD_ENPIN

__LCD_INTERFACE      Interface size. i.e. 4 or 8
__LCD_LINES          Amount of lines
__LCD_TYPE          LCD type (0 to 3)

And they can be used such as:

    PinHigh __LCD_DATA0_PORT.__LCD_DATA0_PIN
    PinLow __LCD_DATA0_PORT_PIN

    PinHigh __LCD_DATA1_PORT.__LCD_DATA1_PIN
    PinLow __LCD_DATA1_PORT_PIN

    PinHigh __LCD_DATA2_PORT.__LCD_DATA2_PIN
    PinLow __LCD_DATA2_PORT_PIN

    PinHigh __LCD_DATA3_PORT.__LCD_DATA3_PIN
    PinLow __LCD_DATA3_PORT_PIN

    PinHigh __LCD_DATA4_PORT.__LCD_DATA4_PIN
    PinLow __LCD_DATA4_PORT_PIN

    PinHigh __LCD_DATA5_PORT.__LCD_DATA5_PIN
    PinLow __LCD_DATA5_PORT_PIN

    PinHigh __LCD_DATA6_PORT.__LCD_DATA6_PIN
    PinLow __LCD_DATA6_PORT_PIN

    PinHigh __LCD_DATA7_PORT.__LCD_DATA7_PIN
    PinLow __LCD_DATA7_PORT_PIN

    PinHigh __LCD_RSPORT.__LCD_RSPIN
    PinLow __LCD_RSPIN_PORT_PIN
    PinHigh __LCD_ENPORT.__LCD_ENPIN
    PinLow __LCD_ENPIN_PORT_PIN

    DelayUs __LCD_COMMANDUS
    DelayUs __LCD_DATAUS

    If __LCD_TYPE = 0 Then
    EndIf

    If __LCD_INTERFACE = 4 Then
    EndIf

    If __LCD_LINES = 2 Then
    EndIf


Then the alias' and constants can come in very handy within a program. However, if a Declare is not used in a program's listing, no constants or alias' will be produced. The alias' and constants are also produces as #define directives in the assembler code listing, because they are created as standard compiler alias' and constants.