Sjaak posted this demo of a KS0074 serial LCD in the forum:

I needed to test the SPI library with the newterm branch. I had a nice display from a dead Siemens phone. It uses a KS0074 display (which is an sort of SPI version of the good old HD44780). I found the datasheet and some example code on the internet  (sorry only German is available). During the testing I found out the Bus Pirate spits out the bits the other way around then in the code/datasheet.

Demo: is a weekly series that demonstrates devices with the Bus Pirate. Come back next Monday for another new demo.

Device: KS0074 LCD
Bus: SPI (pull-up resistors required)
Power requirements: 5 volts (other screens may vary)
References: datasheet, sample code (German)

The display is powered with the Bus Pirate’s on-board 5volt power supply. The screen is 5volts and needs signal levels to be 5volts too. The Bus Pirate pin output is only 3.3volts, but the on-board pull-up resistors can be used for mixed voltage interfacing.

Bus Pirate setup

SPI> i
Bus Pirate v3
Firmware v4.2 (newterm-r296)  Bootloader v4.1
DEVID:0x0447 REVID:0x3043 (B5)
http://dangerousprototypes.com
*———-*
POWER SUPPLIES ON
Voltage monitors: 5V: 5.00 | 3.3V: 3.35 | VPULLUP: 4.98 |
a/A/@ controls AUX pin
Open drain outputs (H=Hi-Z, L=GND)
Pull-up resistors ON
Bitorder configuration not allowed
*———-*
SPI>

From the mode menu (m) configure the Bus Pirate for SPI, any speed, and default clock polarity, edge, and sample phase. Choose open drain output type.

Enable the pull-up resistors (P), and the voltage regulators (W). Be sure the Vpullup pin that feeds the pull-up resistors is connected to the 5volt supply.

Display setup

SPI> [ 0xf8 0xf0 0x00 0x80 0x00 ]
CS ENABLED
WRITE: 0xF8
WRITE: 0xF0
WRITE: 0x00
WRITE: 0x80
WRITE: 0x00
CS DISABLED
SPI>

Display init and clear screen.

SPI> [ 0xfa
CS ENABLED
WRITE: 0xFA
SPI>

Switch to normal input from command mode.

Write text to the display

SPI> 0x40 0x20 0xa0 0xa0 0xc0 0xa0 0x00 0xa0 0x90 0x20 0x40 0xa0 0x80 0x20 0x20 0xa0 0xa0 0x20 0x00 0x40
0xf0 0x20 0x70 0x20 0x00 0x40 0x60 0xa0 0x30 0x20 0xe0 0x20 0xa0 0x20 0xb0 0x20 0x80 0xc0 0x00 0xc0 0x40
0xc0 0x80 0xc0 0x80 0x40 0x80 0x40
WRITE: 0x40

WRITE: 0x40
SPI>

Write text to the first line “BUSPIRATE ON VLGEM1021!!”.

SPI> ]
CS DISABLED
SPI>

Take CS low to finish the command.

Custom characters


SPI> [ 0xf8 0x00 0x20 ]
CS ENABLED
WRITE: 0xF8
WRITE: 0x00
WRITE: 0x20
CS DISABLED
SPI>

Set the custom character cursor to CHRAM position 0x00.

SPI> [ 0xfa 0x20 0x00 0xf0 0x80 0xf0 0x80 0x70 0x00 0x70 0x00 0x20 0x00 0xf0 0x80 0x20 0x00 ]
CS ENABLED
WRITE: 0xFA

WRITE: 0x00
CS DISABLED
SPI>

Program a diode to chram pos 0x00.

SPI> [ 0xfa 0x80 0x80 0x50 0x00 0x20 0x00 0x20 0x00 0x20 0x00 0x20 0x00 0x00 0x00 ]
CS ENABLED
WRITE: 0xFA

WRITE: 0x00
CS DISABLED
SPI>

Program an antenna to chram at 0x01 (no need to set address again).

SPI> [ 0xF8 0x00 0x30 ]
CS ENABLED
WRITE: 0xF8
WRITE: 0x00
WRITE: 0x30
CS DISABLED
SPI>

Move to the second line.

SPI> [ 0xFa 0x00 0x00 0x80 0x00 ]
CS ENABLED
WRITE: 0xFA
WRITE: 0x00
WRITE: 0x00
WRITE: 0x80
WRITE: 0x00
CS DISABLED
SPI>

Display the custom character on line 2.

Taking it further

Check the Bus Pirate manual for a complete list of chip demonstrations. Requests are always appreciated.

Advertisements