News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

PCF8566 LCD driver (or similar) example code

Started by broderic, Oct 09, 2022, 08:39 AM

Previous topic - Next topic

broderic

Hello.
I'm trying to drive a segmented LCD with PIC16F877 and PCF8566 driver, using I2C.
But I can find any simple code example for that (initialization and load simple data).
The PCF8566 data sheet for me is not clear enough on how to initialize and send data (how to sequence the commands, which first and which last).

Does anyone know where code examples can be found?

Thank you

HAL

Hi  Broderic

There is an example of I2C with PCF8574 under the tab I2C Lcd Code Examples.
Hope it helps.

Regards Hal
 

HAL

Hi  Broderic

Whoops! Please ignore my post. I should have read more closely.
I assumed "drive a segmented LCD" was a display and having found the data sheet I realize my error....
Mia Culpa.
 

Parmin

Not sure if this would help, it has been a few years since I used this.
It was for old Nokia 5110 LCD



Include "Font6x8.inc"      ; font file (DIY or download as required)

; Symbols to setup pins - change pin designations accordingly
 ; LCD pins
    Symbol  RsT        = LATA.2      : Output RsT          ; reset LCD
    Symbol  CEL        = LATC.0      : Output CEL          ; LCD Chip Enable
    Symbol  MOL        = LATC.1      : Output MOL          ; LCD SDA / SSP SDO2
    Symbol  DC          = LATC.2      : Output DC          ; LCD D/C pin
    Symbol  SckL        = LATB.7      : Output SckL        ; LCD SCK / SSP SCK2
    Symbol  VLcD        = LATC.4      : Output VLcD        ; LCD power
    Symbol  LED        = LATC.5      : Output LED          ; LCD backlight



; =========================================================== LCD Subs  ==========
; LCD 5110 Initialize routine         
InitLCD:
    High VLcD                  ; powerup LCD
    DelayMS 10
    ContrASt = ERead 0
    TC      = ERead 1
    Bias    = ERead 2 
   
    Low CEL
    High RsT
    DelayMS 5
    Low RsT
    Nop
    High RsT
    High CEL
    Nop
 
    Low CEL              ; start comm
    Low DC              ; the following is COMMAND
    SHOut MOL,SckL,1,[$21,ContrASt,TC,Bias,$20,$0C]
    High CEL            ; stop comm
    Return

;==========================================================   
; move crusor to Xand Y position   
$define XY (x,y)'
    Xpos = x '
    Ypos = y '
    GoSub GotoXY
GotoXY:
    Low DC
    Xpos  = $40 + Xpos
    Ypos  = $80 + Ypos
    SHOut MOL,SckL,1,[Xpos,Ypos]
    Return 

; =========================================================
; clear LCD   
$define cleaRLcd'
    GoSub ClrLCD                                       
ClrLCD:
    XY (0,0)
    y = 0
    High DC
    Repeat
      x = 0
      Repeat
        SHOut MOL,SckL,1,[0]
        Inc x
      Until x = 85
      Inc y
    Until y = 9
    Return
   
; ===========================================  print line
;  command Prnt (y,x, "text")
;  Y = line number 0 to 5
;  x = character position number 0 - 13
$define Prnt (y, x, LcdStr) '     
    Xpos = x '
    Ypos = y '
    lineSTR = LcdStr '
    GoSub LCDLinePrinT
LCDLinePrinT:
    Low DC                            ; command
    Xpos = Xpos * 6                    ; each character require 6 spaces
    Xpos = $80 + Xpos                  ; set X position
    Ypos = $40 + Ypos                  ; set Y position
    SHOut MOL,SckL,1,[Xpos,Ypos]
   
    High DC                            ; DATA
    y = 0                              ; reset character index
    While 1=1
      chaRACter = lineSTR[y]            ; get character
      If chaRACter = 0 Then Break      ; until end of line
      charindex = chaRACter * 6        ; each character is 6 bytes of info
      index = 0                        ; clear info index
      Repeat           
              x = LRead FONTTable + charindex + index    ; read info on index
              SHOut MOL,SckL,1,[x]      ; send to LCD
              Inc index
      Until index = 6
      Inc y                            ; do next character
    Wend
    Return

Pepe

I have published a demo with this corrected library