News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Alphanumeric (Hitachi HD44780) LCD Print Declares.

Started by basiclover, Dec 08, 2021, 11:16 AM

Previous topic - Next topic

basiclover

The manuaal says:
The LCD may be connected to the microcontroller using either a 4-bit bus or an 8-bit bus. If an
8-bit bus is used, all 8 bits must be on one port. If a 4-bit bus is used, it must be connected to
either the bottom 4 or top 4 bits of one port. For example: -
Declare LCD_DTPin PORTB.4 ' Used for 4-line interface.
Declare LCD_DTPin PORTB.0 ' Used for 8-line interface.

I understand  that the above 4 line interface declare assigns data lines to PortB4 up to port B7
How to assign instead to portB0 up to portB3 ?

trastikata

Declare LCD_Interface = 4
Declare LCD_DTPin PORTB.0

or you can select individual pins

Declare LCD_Data4_Pin PORTB.0
Declare LCD_Data5_Pin PORTB.1
Declare LCD_Data6_Pin PORTB.2
Declare LCD_Data7_Pin PORTB.3

Gamboa

Hi,

This was the case initially, but Les added another more flexible form that can be used. If you keep reading the manual you will find:

QuoteDeclare LCD_DataX_Pin = Port.Pin
Assigns the individual Ports and Pins that the HD4470 LCD's DT lines will attach to.
Unlike the above LCD_DTPin declares, the LCD's data pins can also be attached to any separate port and pin. For example:-
Declare LCD_Data0_Pin PORTA.0 ' Connect PORTA.0 to the LCD's D0 line
Declare LCD_Data1_Pin PORTA.2 ' Connect PORTA.2 to the LCD's D1 line
Declare LCD_Data2_Pin PORTA.4 ' Connect PORTA.4 to the LCD's D2 line
Declare LCD_Data3_Pin PORTB.0 ' Connect PORTB.0 to the LCD's D3 line
Declare LCD_Data4_Pin PORTB.1 ' Connect PORTB.1 to the LCD's D4 line
Declare LCD_Data5_Pin PORTB.5 ' Connect PORTB.5 to the LCD's D5 line
Declare LCD_Data6_Pin PORTC.0 ' Connect PORTC.0 to the LCD's D6 line
Declare LCD_Data7_Pin PORTC.1 ' Connect PORTC.1 to the LCD's D7 line
There are no default settings for these Declares and they must be used within the BASIC program if required.

regards,
Gamboa
Long live for you

basiclover

thanks, I saw this
but that doesn't tell the display to work in the four data lines mode

trastikata

Quote from: basiclover on Dec 08, 2021, 12:07 PMthanks, I saw this
but that doesn't tell the display to work in the four data lines mode

Maye you missed it in my previous post:
 
Declare LCD_Interface = 4

basiclover

thanks trastikata, I understand this now
I was using an old proton manual where "Declare LCD_Interface = 4 " is not mensioned. Found it in the positron manual

Stephen Moss

Quote from: Gamboa on Dec 08, 2021, 11:44 AMHi,

This was the case initially, but Les added another more flexible form that can be used.
It may be more flexible but I expect it would be slower and bulkier as the resulting code has to chop the data into more pieces and manipulate more I/O pins.

top204

The Declare LCD_Interface has always been in the manuals from day one. In the Compiler Declares section, under LCD Declares.

Seperating the pins does cause slightly more code memory to be used because it has to write each individual pin as a virtual port, but speed is not an issue, because Hitachi type alphanumeric LCDs are actually quite slow themselves, and will lock if data is sent to them too quickly, hence the internal delays in the compiler's library commands subroutines.