'27-4-00 'Test code for HG12605 128*64 graphical LCD display 'Pin allocation ' control signals Di Alias P1.4 '1 data, 0 instruction Rw Alias P1.5 '1 read, 0=write E Alias P1.2 'clock Cs1 Alias P1.3 'active high select left half of display Cs2 Alias P1.0 'active high select right half of display Res Alias P1.1 'active low reset ' data lines Dbus Alias P3 'General method of communication 'WRITE - set up control lines, raise E, write setup data, lower E, repeat 'READ - set up control lines, raise E, read data, lower E, repeat 'INITIALISE DISPLAY 'Reset display and initialise lines to resting state Res = 0 'reset active Di = 0 'instruction Rw = 1 'read E = 0 'clock low Cs1 = 0 : Cs2 = 0 'deselect both chips Waitms 10 'delay for a while, I assume non-critical 'Un-reset display Res = 1 'release rest line Waitms 10 'allow it to come out of reset (may not be necessary)s 'Turn display on WRITE 00 00111111 Rw = 0 Di = 0 Cs1 = 1 : Cs2 = 1 'select both chips E = 1 'clock high Dbus = &B00111111 'setup data for falling edge E = 0 'clock in data Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop 'just in case 'Set page (X address) (to zero) Rw = 0 Di = 0 Cs1 = 1 : Cs2 = 1 'select both chips E = 1 'clock high Dbus = &B10111000 'setup data for falling edge E = 0 'clock in data Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop 'just in case 'Preset column (Y address) (to zero) Rw = 0 Di = 0 Cs1 = 1 : Cs2 = 1 'select both chips E = 1 'clock high Dbus = &B01000000 'setup data for falling edge E = 0 'clock in data Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop 'just in case Dim Num As Byte Dim X As Byte Dim Xx As Byte ' Pre-setup control lines (they don't need to change) Rw = 0 'write Di = 1 'data Cs1 = 1 : Cs2 = 1 'leave both chips selected (no reason why not) Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop 'just in case 'Now write a moving patten into the columns For X = 0 To 63 Step 8 Num = 1 For Xx = 0 To 7 E = 1 'clock high Dbus = Num 'setup data for falling edge E = 0 'clock in data Rotate Num , Left 'move pixel down one for next line Next Next