Set up the device to use an LCD
Description:
This is a function that initializes LCD variables. This includes the selection of the lines used for RW, RS, E and the port used for data. RW, RS, and E are reset. These commands are appropriate for HD44780 devices and devices that are compatible.
Command Syntax: (USBm.dll)
USBm_InitLCD( device, sel, port )
The USBm_InitLCD function syntax has these parts:
Part | Description |
device | A zero-based index to address the appropriate USB device. |
sel | Selection of the RW line in the higher nibble, and the RS line in the lower nibble. |
port | Selection of the LCD data port in the higher nibble, and the E line in the lower nibble. A value of 0-h is port A, a value of 1-h is port B. |
Remarks:
Bit⁄Line Selection
Byte Value | Result | Byte Value | Result | |
00h | Affect A.0 | 08h | Affect B.0 | |
01h | Affect A.1 | 09h | Affect B.1 | |
02h | Affect A.2 | 0Ah | Affect B.2 | |
03h | Affect A.3 | 0Bh | Affect B.3 | |
04h | Affect A.4 | 0Ch | Affect B.4 | |
05h | Affect A.5 | 0Dh | Affect B.5 | |
06h | Affect A.6 | 0Eh | Affect B.6 | |
07h | Affect A.7 | 0Fh | Affect B.7 |
VB Declaration
Public Declare Function USBm_InitLCD _ Lib “USBm.dll” _ (ByVal device As Byte, _ ByVal sel As Byte, _ ByVal port As Byte) _ As Integer |
VB Example
USBm_InitLCD 2, &H89, &H0A |
This code fragment will select port A for the data lines to the LCD, B.0 for the RW line, B.1 for the RS line, and B.2 for the E line.
C Prototype
int USBm_InitLCD( unsigned char device, unsigned char sel, unsigned char port ); |
C Example
RobotBASIC
usbm_InitLCD(ne_DeviceNumber,ne_Sel, ne_Port)
Returns true if successful, false otherwise. It specifies the port to use for the data port and the pins to use for the R⁄W, RS, and E lines for controlling an LCD.
Raw Command Format:
Byte Number | Description |
0 | 10h: InitLCDCmd |
1 | RW line selection, RS line selection |
2 | Data port, E line selection |
3 | <not used> |
4 | <not used> |
5 | <not used> |
6 | <not used> |
7 | <not used> |
Raw Command Format Details:
Byte 0 contains the command. Byte 1 selects the RW line in the higher nibble and the RS line in the lower nibble. Byte 2 selects the port to write the byte in the higher nibble, and the E line in the lower nibble. A value of 0-h is port A, a value of 1-h is port B. Byte 3 through byte 7 are unused.
Bit⁄Line Selection
Byte Value | Result | Byte Value | Result | |
00h | Affect A.0 | 08h | Affect B.0 | |
01h | Affect A.1 | 09h | Affect B.1 | |
02h | Affect A.2 | 0Ah | Affect B.2 | |
03h | Affect A.3 | 0Bh | Affect B.3 | |
04h | Affect A.4 | 0Ch | Affect B.4 | |
05h | Affect A.5 | 0Dh | Affect B.5 | |
06h | Affect A.6 | 0Eh | Affect B.6 | |
07h | Affect A.7 | 0Fh | Affect B.7 |
Raw Command Response Format:
Byte Number | Description |
0 | 10h: InitLCDCmd |
1 | <not used> |
2 | <not used> |
3 | <not used> |
4 | <not used> |
5 | <not used> |
6 | <not used> |
7 | <not used> |
Raw Command Response Format Details:
Byte 0 contains the command. Byte 1 through byte 7 are unused.
Raw Command Example Usage:
The command 10-89-0A-00-00-00-00-00 will select port A for the data lines to the LCD, B.0 for the RW line, B.1 for the RS line, and B.2 for the E line.