BPv4 HD66717 I2C demo
From DP
Everyone knows the HD44780 LCD controller but there are many others.
This demo is about the "BT21605AV-YETF-LED04-I2C" 2x16 LCD module with the less common HD66717 controller in I2C mode.
Overview
- Chip: HD66717
- Bus: I2C, pull-up resistors required.
- Power: 2.7-5.5v
- Reference:HD66717 Controller, Datasheet of the display, Second datasheet with the I2C address
Connecting this display requires a minimal of four connections.
Code: Select all Connections BP LCD SDA SDL SCL SCL +5V VDD GND GND also connect 3.3V back to VPU on the Bus Pirate
Fist we need to setup the Bus Pirate to use the I2C protocol.
Code: Select all HiZ>m << Enter mode selection 1. HiZ 2. 1-WIRE 3. I2C 4. SPI 5. 2WIRE 6. 3WIRE 7. LCD 8. DIO x. exit(without change) (1)>3 << Select I2C I2C mode: 1. Software 2. Hardware (1)>2 << Select Hardware Set speed: 1. 100KHz 2. 400KHz 3. 1MHz (1)>1 << Select 100KHz Ready I2C>W << Enable PSU Power supplies ON I2C>P << Enable pull-ups Pull-up resistors ON I2C>
In the second datasheet we found the default I2C address but we use the search option of the Bus Pirate to make sure.
Code: Select all I2C>(1) << Finding the Controller Searching I2C address space. Found devices at: 0x70(0x38 W) 0x72(0x39 W) I2C>
0x70 is the instruction address and 0x72 is the data address. This controller is write only so we can't get any data back.
Now we are going to initialize the controller. For more details see page 39 of the HD66717 datasheet.
Code: Select all I2C> I2C>[0x70 << Addressing the controller for instructions I2C START BIT WRITE: 0x70 ACK I2C>0x1C << Power control WRITE: 0x1C ACK I2C>0x4F << Contrast control WRITE: 0x4F ACK I2C>0x0F << Cursor control WRITE: 0x0F ACK I2C>0x14 << Display on/off control WRITE: 0x14 ACK I2C>] << We are done initializing the controller. I2C STOP BIT I2C>
This display is addressed as and LCD with 4 lines. Each line in the controller is 12 characters long however we can only see 8 characters of them, so after 8 useful characters we need to send 4 useless ones to get back on the screen.
Sending
Code: Select all <Line 1>@@@@{Line 2}@@@@[Line 3]@@@@(Line 4)@@@@
will result in the following and get us back home:
Code: Select all <Line 1>{Line 2} [Line 3](Line 4)
Now we can send something useful to the controller to finally see something on the screen.
Code: Select all I2C>[0x70 0x02] << first we go back home I2C START BIT WRITE: 0x70 ACK WRITE: 0x02 ACK I2C STOP BIT I2C>[0x72 0x3c 0x4c 0x69 0x6e 0x65 0x20 0x31 0x3e] << sending "<Line 1>" I2C START BIT WRITE: 0x72 ACK WRITE: 0x3C ACK WRITE: 0x4C ACK WRITE: 0x69 ACK WRITE: 0x6E ACK WRITE: 0x65 ACK WRITE: 0x20 ACK WRITE: 0x31 ACK WRITE: 0x3E ACK I2C STOP BIT I2C>[0x72 0x40 0x40 0x40 0x40] << skipping past the 4 hidden characters I2C START BIT WRITE: 0x72 ACK WRITE: 0x40 ACK WRITE: 0x40 ACK WRITE: 0x40 ACK WRITE: 0x40 ACK I2C STOP BIT I2C>
Now its easy to send anything we want.
Code: Select all [0x70 0x1c 0x4f 0x0f 0x14] ;initialize [0x70 0x02] ;return home [0x72 0x3c 0x4c 0x69 0x6e 0x65 0x20 0x31 0x3e] ;<Line 1> [0x72 0x40 0x40 0x40 0x40] ;@@@@ [0x72 0x7b 0x4c 0x69 0x6e 0x65 0x20 0x32 0x7d] ;{Line 2} [0x72 0x40 0x40 0x40 0x40] ;@@@@ [0x72 0x5b 0x4c 0x69 0x6e 0x65 0x20 0x33 0x5d] ;[Line 3] [0x72 0x40 0x40 0x40 0x40] ;@@@@ [0x72 0x28 0x4c 0x69 0x6e 0x65 0x20 0x34 0x29] ;(Line 4) [0x72 0x40 0x40 0x40 0x40] ;@@@@ [0x70 0x02] ;return home [0x72 0x42 0x75 0x73 0x50 0x69 0x72 0x61 0x74 0x40 0x40 0x40 0x40 0x65 0x76 0x34 0x20 0x44 0x61 0x6e 0x67 0x40 0x40 0x40 0x40 0x65 0x72 0x6f 0x75 0x73 0x20 0x50 0x72 0x40 0x40 0x40 0x40 0x6f 0x74 0x6f 0x74 0x79 0x70 0x65 0x73 0x40 0x40 0x40 0x40] ;BusPirat@@@@ev4 Dang@@@@erous Pr@@@@ototypes@@@@
Note this is only the basic stuff for this controller, like the HD44780 it also has the ability to use custom characters (8 for the HD44780 and 4 for the HD66717) and it has software controlled contrast.


