• PicŪ Basic


  • LM6029 (132 x 65) LCD / ST7565 Chipset

    I was quite peeved when I started using this display. The documantation is poor in the sense that there is no clear pointers on how you should issue commands. All you see here required a LOT of experimantation.

    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
    Next you have to initialize the LCD. I used PortD as the LCD data bus and I used 8 data bits. Aparently you can use 4 data bits as well.

    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
    Remember to Tris the port for IN / OUTPUT or it will not work.
    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 /
    This is a page and column setup. Check the data sheet how each works ok !

    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
    This is writing a small letter 'h'

    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
    This is writing a capital 'B' spanning over two pages

    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
    Note I have made my characters each a call routine. You set up the page, then the column adress, then do a Gosub BB to write the top half of the 'B'. You then set up the next page, then the same column adress, then do a Gosub BB1. If the adresses are not the same you will get an offset top and bottom character.

    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
  • Recent Activity

    Stephen Moss-711

    Select a choice of include file

    Thread Starter: Dave-S

    Is there any way to select a choice of a include file, ie: by holding a button connected to a Pin?

    Stephen Moss Today, 09:19 Go to last post
    crankshaft-122

    I2C Slave problems with 12F1840

    Thread Starter: crankshaft

    Spent the last 2 days on this and are hoping someone can help, as I have googled and tried lots of things and there's not much in these forums...

    crankshaft Today, 11:35 Go to last post
    charliecoultas-16125

    PicKit3 Programmer

    Thread Starter: Dave-S

    Trying to setup a PicKit3 Programmer. Has gone through the install programmer and the Dos screen flashes up but does not stay there, and it does not...

    charliecoultas Today, 08:29 Go to last post
    towlerg-21522

    Issue with MID$

    Thread Starter: Frizie

    Hi people! I have a small issue with the MID$ command. If I put a semi-colon in the source-string then I get the compiler error: Unbalanced...

    towlerg Yesterday, 22:22 Go to last post