The reason for choosing this graphics display is it draws very little current. A total of less than 12mA and that is with a pressure sensor and backlight on and the PICŪ is not in sleep. I used the 18F24k20 and ran it at 8Mhz.
The ST7565 timing requires ~400ns for a system cycle time. To use a slow enough clock I chose 8MHz on the PICŪ that would give 8MHz / 4 = 2MHz ~ 500ns. As long as the PICŪ is slower than the LCD you are safe with timing issues.
The ST7565 chipset actuall has some very nice features once you get the hang of it. Screen scrolling etc are all fancy stuff you can do with it. Here I'm only going to give some pointers on getting started with it, the easy way.
Before you start with the LCD, allow some time for everything to start up properly. This is simply done by holding the LCD reset pin in reset.
Code:
Symbol LCDRes = LATC.0 ' LCD RESET Output
LCDRes = 0
DelayMS 500 ' Allow power up
LCDRes = 1 ' Release the reset
Regarding controlling the LCD, note the following. You'll use this all the time !
LCD COMMANDS are sent with A0 = 0 : RD = 1 : WR = 0 (Command Mode)
Data Writes are sent with A0 = 1 : RD = 1 : WR = 0 (Data Mode)
Data Reads are done with A0 = 1 : RD = 0 : WR = 1 (Read Mode)
Clock each thing you do with CS1 = 0 : CS1 = 1, or the action won't take place.
To issue a command you need to set the command on the data port,
Then set the control lines A0, RD and WR in command mode (as above), then clock the lot into the LCD
This btw is a lot like clocking serial data over.
Like this -
PORTD = $40 : A0 = 0 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1 'Select Display start line 0
To send data to the LCD it looks like this -
PORTD = $00 : A0 = 1 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1
And to read data it looks like this -
A0 = 1 : RD = 0 : WR = 1 : CS1 = 0 : CS1 = 1 : Variable = PortD
One of the trics with reading from the LCD is to do one dummy read before the first read,
then do the real read, like this
Code:
Dim InH as Byte
TRISD = %11111111 'Read with PortD
' Select Read mode
A0 = 1 : RD = 0 : WR = 1 : CS1 = 0 : CS1 = 1 'Do a dummy read first
CS1 = 0 : CS1 = 1 'Then a read
InH = PORTD
After the first dummy read, then a read, you can clock the data out without further dummy reads,
untill you quit the read mode and enters it again.
Here is the initiallize routine.
Code:
PORTD = $40 : A0 = 0 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1 'Display start line 0 PORTD = $A0 : CS1 = 0 : CS1 = 1 'ADC reverse, write right to left PORTD = $C8 : CS1 = 0 : CS1 = 1 'Inverse Display $C0 PORTD = $A6 : CS1 = 0 : CS1 = 1 'Flips Characters $A7 PORTD = $A2 : CS1 = 0 : CS1 = 1 'Set bias 1/9 (Duty 1/65) PORTD = $2F : CS1 = 0 : CS1 = 1 'Booster, Regulator and Follower on PORTD = $F8 : CS1 = 0 : CS1 = 1 'Set internal Booster to 4x F8 PORTD = $00 : CS1 = 0 : CS1 = 1 'Set internal Booster to 4x PORTD = $26 : CS1 = 0 : CS1 = 1 'Contrast set viewing Angle $27 - Top & Bottom view, $25 Light, S26 Dark PORTD = $81 : CS1 = 0 : CS1 = 1 'Contrast set PORTD = $16 : CS1 = 0 : CS1 = 1 'Contrast set PORTD = $AC : CS1 = 0 : CS1 = 1 'No indicator PORTD = $00 : CS1 = 0 : CS1 = 1 'No indicator PORTD = $AF : CS1 = 0 : CS1 = 1 'Display on - Configuration finished here. PORTD = $A5 : CS1 = 0 : CS1 = 1 'All display ON \ DelayMS 500 '- Optional, Black display for 500ms PORTD = $A4 : CS1 = 0 : CS1 = 1 'All display OFF /
Code:
' Select Page 5
PORTD = $B5 : A0 = 0 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1 'Select page
PORTD = $10 : CS1 = 0 : CS1 = 1 'Select column 0 MSB
PORTD = $00 : CS1 = 0 : CS1 = 1 'Select column 0 LSB
Code:
SSh: '00 7F 08 08 70
PORTD = $00 : A0 = 1 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1
PORTD = $7F : CS1 = 0 : CS1 = 1
PORTD = $08 : CS1 = 0 : CS1 = 1
PORTD = $08 : CS1 = 0 : CS1 = 1
PORTD = $70 : CS1 = 0 : CS1 = 1
Return
Code:
BB: '00 FF FF C3 C3 C3 C3 E7 FE 3C 00
PORTD = $00 : A0 = 1 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1
PORTD = $FF : CS1 = 0 : CS1 = 1
PORTD = $FF : CS1 = 0 : CS1 = 1
PORTD = $C3 : CS1 = 0 : CS1 = 1
PORTD = $C3 : CS1 = 0 : CS1 = 1
PORTD = $C3 : CS1 = 0 : CS1 = 1
PORTD = $C3 : CS1 = 0 : CS1 = 1
PORTD = $E7 : CS1 = 0 : CS1 = 1
PORTD = $FE : CS1 = 0 : CS1 = 1
PORTD = $3C : CS1 = 0 : CS1 = 1
PORTD = $00 : CS1 = 0 : CS1 = 1
Return
BB1: '00 7F 7F 60 60 60 60 71 3F 1F 00
PORTD = $00 : A0 = 1 : RD = 1 : WR = 0 : CS1 = 0 : CS1 = 1
PORTD = $7F : CS1 = 0 : CS1 = 1
PORTD = $7F : CS1 = 0 : CS1 = 1
PORTD = $60 : CS1 = 0 : CS1 = 1
PORTD = $60 : CS1 = 0 : CS1 = 1
PORTD = $60 : CS1 = 0 : CS1 = 1
PORTD = $60 : CS1 = 0 : CS1 = 1
PORTD = $71 : CS1 = 0 : CS1 = 1
PORTD = $3F : CS1 = 0 : CS1 = 1
PORTD = $1F : CS1 = 0 : CS1 = 1
PORTD = $00 : CS1 = 0 : CS1 = 1
Return
I will post some more on this when I get a bit of time, but this should get you going. Wish I had this to start with ;-))
Controller datasheet: http://www.displaytech-us.com/pdf/ap...V17_960601.pdf


Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit