• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

12864AP1 HW setup question


New member
I hope this is the correct forum.

I'm designing some hardware using the CFAX12864AP1 module (beautiful little unit). Before I get too far on the prototype, though, I wanted to verify some things. I want to use the unit in Serial Mode. In this mode (P/S=0) what would be the appropriate settings for the other pins? DB0-DB5 become high impedance, but high-Z inputs or outputs? If inputs should they be tied to Vcc/Gnd? If so, what would be an appropriate value for the pull up/down resistors? In fact, is it be okay to tie any signal pins directly to Vcc or Gnd or can you recommend a pull-u/d resistor value? Also, what is the best thing to do with the MI pin in serial mode? I assume it is meaningless and can be tied either hi or low?

I've looked through the controller spec and it seems that it would be possible to drive the unit serially using an SPI bus. Does anyone have any advice as to how this should be done? I have seen that it is recommended that byte boundaries be indicated by toggling the CS pins which would work well with the SPI bus and the timings/signalling are compatible.

Thanks in advance for your help!
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.

CF Tech

Going down the list, I would think this would be correct:
1  VDD  3.3v
2  VSS  ground
3  CS1B low
4  CS2  high
5  RES  (low at power-on, then high for operation, can drive with a port pin)
6  RS   low/high as needed to write to the control or display
7  R/W  low (should be a don't care, but do not leave it floating)
8  E    high (should be a don't care, but do not leave it floating)
9  DB0  (see [b]note[/b])
10 DB1  (see [b]note[/b])
11 DB2  (see [b]note[/b])
12 DB3  (see [b]note[/b])
13 DB4  (see [b]note[/b])
14 DB5  (see [b]note[/b])
15 DB6  SPI serial data clock
16 DB7  SPI serial data input
17 MI   low (should be a don't care, but do not leave it floating)
18 PS   low
note I could not find the "pull-up" you mention for these pins. I would tie them high.

It is OK to tie the pins directly high or low. The pull-ups were required for TTL logic, but CMOS is fine to tie directly to the rail.


New member
perfect -- first time

Works beautifully with some example init code I found in amongst these forums.

Thanks for your help!

general info:
silabs c8051f226-tb demo board connected to prototype lcd board holding CAFX12864-AP1.
8051 in SPI master master mode (phase & polarity bits set to reverse).
RS/RES general purpose IO.
Pins connected exactly as described.

CF Tech

If you are feeling generous to future people that might have the same kind of project . . . it is perfectly fine to post sample code here :)


New member
sample code


For the Silabs 8051 microcontrollers (F2xx series)

I have yet to find the "magic" formula to reliably write to the display, but my hardware setup is a little hokey -- SPI lines are very long and not properly shielded. This setup routine works consistently when external noise is minimized, though.
$MOD8F200                  ; Include regsiter definition file.

;GREEN_LED    EQU   P2.4        ; Port I/O pin connected to Green LED.  

RS            EQU   P2.4
RES           EQU   P2.5



          ; Reset Vector
          org 00h         
          ljmp  Main          ; Jump beyond interrupt vector space.


          org 0B3h          ; End of interrupt vector space.

Main:       ; Disable the WDT. (IRQs not enabled at this point.)
          ; If interrupts were enabled, we would need to explicitly disable
          ; them so that the 2nd move to WDTCN occurs no more than four clock 
          ; cycles after the first move to WDTCN.
          mov WDTCN, #0DEh
          mov WDTCN, #0ADh

          ; Enable the SPI interface:
          mov SPI0CFG, #11000111b
          mov SPI0CN,  #00000011b
          mov SPI0CKR, #020h 

          ; Set P2.4 and 2.5 as P-P outputs
          mov PRT2CF, #11111100b
          ; route spi to pins:
          mov PRT2MX, #00000001b

          mov P2, #00111000b

; Pin assignments:
; P2.4 = RESet
; P2.5 = RS
; P2.2 = SDAT
; P2.0 = SCLK

          ;Initialize the Display
          acall Delay
          acall Delay
          clr RES

          ;now wait a little while
          acall Delay
          acall Delay
          acall Delay

          setb RES

          ; now run init routine:
          ; since these are all commands, clear RS line:
          clr RS

          acall Delay
          acall Delay

          ;Software reset command
          ;mov SPI0DAT, #0E2h 
          ;jnb SPI0CN.7, $
          ;clr SPI0CN.7
          ;jmp test_loop

          ;acall Delay

          ;ADC (A0, A1) (Flips display left to right, assuming landscape 

          mov SPI0DAT, #0A1h
          acall Delay

          ;SHL (C8 C0) (Flips display top to bottom, assuming landscape 
          mov SPI0DAT, #0C8h
          acall Delay

          ;LCD Bias (A2 A3)
          mov SPI0DAT, #0A3h
          acall Delay

          ;Display normal EON
          mov SPI0DAT, #0A4h
          acall Delay

          ;Display normal REV
          mov SPI0DAT, #0A6h
          acall Delay

          ;Resistor (20 - 27)   
          mov SPI0DAT, #026h
          acall Delay
          acall Delay

          ; Reference voltage(contrast)
          mov SPI0DAT, #081h
          acall Delay_short

          ;displayContrast is nominally 50
          mov SPI0DAT, #050h
          acall Delay

;//0xE2, 0xA1, 0xC0, 0xA3, 
;//;0xA6, 0x26, 0x81, 0x20, 
;//;0x2C, 0x2E, 0x2F, 

          mov SPI0DAT, #02Ch
          acall Delay

          mov SPI0DAT, #02Eh
          acall Delay

          mov SPI0DAT, #02Fh
          acall Delay
          acall Delay
          acall Delay
          acall Delay

;//;0xAF, 0x40, 0xB0, 0x10, 0x04

                 ;Display on
          mov SPI0DAT, #0AFh
          acall Delay
          acall Delay
          acall Delay
          acall Delay

          ;Initial Display Line
          mov SPI0DAT, #040h
          acall Delay

          ; page address:
          mov SPI0DAT, #0B0h
          acall Delay

          ; column 
          mov SPI0DAT, #010h        ; MSB
          acall Delay_short

          mov SPI0DAT, #04h       ; LSB
          acall Delay

          ;Display is ready to accept data.

[COLOR="Red"]         jmp $ ; your code here

          mov R2, #03h
          mov R1, #0h         
          mov R0, #0h
          djnz R0, $
          djnz R1, delay_1
          djnz R2, delay_0

          mov R1, #0Fh          
          mov R0, #0h
          djnz R0, $
          djnz R1, delay_s_1
(admin edit: fix tabs and "code" tags)

CF Tech

Thanks for the sample code.

I think that code may be useful for anyone using a Silabs 8051 on a c8051f226-tb demo board to initialize a the Samsung KS0713 / S6B1713 controller on the CFAX12864AP1 using the SPI interface.

(trying to plant the seeds so the search engines can find the thread ;) )