I2c lcd protocol

From BitWizard WIKI
Revision as of 16:43, 4 July 2013 by Rew (talk | contribs) (outdated)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

outdated

This page is outdated. Please use the Lcd_protocol_1.6 page.

----- old info follows: -----

The addresses on the I2C bus are 7 bits wide. The lower bit specifies if the transaction is to be a read or a write. Write transactions have the lower bit cleared (0), read transactions have the lower bit set (1).

Each transaction on the I2C bus starts with the address of the board. The i2c_lcd board will ignore any transactions on the I2C bus that do not start with its own address.

After the address a single byte indicates the "port" on the board that the data is written to. The software can thus define 256 ports on each board.

Also see the general I2C protocol

write ports

Some ports just set a single value. So writing more than one byte to such a port is redundant. Other ports are logically a stream of bytes. So writing more than one byte is encouraged.

The spi_lcd board defines several ports.

port function
0x00 display data.
0x01 write data as command to LCD.
0x10 any data clears the screen.
0x11 move the cursor to line l, position p.
l is the top 3 bits
p is the bottom 5 bits of the data.
0x12 set contrast.
0x13 set backlight.
0xf0 change address.

read ports

The i2c_lcd board supports two read ports:

port function
0x01 identification string. (terminated with 0).
0x02 read eeprom (serial number).

examples

read identification

read the identification string of the board. ('i2c_lcd 1.4').

data sent explanation
START create a START condition on the bus.
0x82 select destination with address 0x82 for WRITE.
0x01 identify port
STOP create a STOP condition on the bus.
START create a START condition on the bus.
0x83 select destination with address 0x82 for READ
0x69 'i'
0x32 '2'
0x63 'c'
... etc.

Send text to display

Display the string "Hello World!" (only the first 5 bytes of the string shown).

data sent explanation
START create a START condition on the bus.
0x82 select destination with address 0x82 for WRITE
0x00 datastream
0x48 'H'
0x65 'e'
0x6c 'l'
0x6c 'l'
0x6f 'o'
xx etc.

set cursor position

move to line 1, character 5:

data sent explanation
START create a START condition on the bus.
0x82 select destination with address 0x82 for WRITE
0x11 port 0x11 = set cursor position.
0x25 0x25 = 001 00101 = line 1 position 5.
STOP create a STOP condition on the bus.