This is what I used to test my Nokia color LCDs with 16F627...
Code:
W EQU H'0000'
F EQU H'0001'
CMD EQU H'0000'
DAT EQU H'0001'
;----- Register Files------------------------------------------------------
INDF EQU H'0000'
TMR0 EQU H'0001'
PCL EQU H'0002'
STATUS EQU H'0003'
FSR EQU H'0004'
PORTA EQU H'0005'
PORTB EQU H'0006'
INTCON EQU H'000B'
OPTION_REG EQU H'0081'
TRISA EQU H'0085'
TRISB EQU H'0086'
CMCON EQU H'001F'
;----- STATUS Bits --------------------------------------------------------
IRP EQU H'0007'
RP1 EQU H'0006'
RP0 EQU H'0005'
NOT_TO EQU H'0004'
NOT_PD EQU H'0003'
Z EQU H'0002'
DC EQU H'0001'
C EQU H'0000'
;==========================================================================
;
; RAM Definition
;
;==========================================================================
__MAXRAM H'01FF'
__BADRAM H'07'-H'09', H'0D', H'13'-H'14', H'1B'-H'1E'
__BADRAM H'87'-H'89', H'8D', H'8F'-H'91', H'93'-H'97', H'9E'
__BADRAM H'105', H'107'-H'109', H'10C'-H'11F', H'150'-H'16F'
__BADRAM H'185', H'187'-H'189', H'18C'-H'1EF'
;==========================================================================
;
; Configuration Bits
;
;==========================================================================
_BODEN_ON EQU H'3FFF'
_BODEN_OFF EQU H'3FBF'
_CP_ALL EQU H'03FF'
_CP_75 EQU H'17FF'
_CP_50 EQU H'2BFF'
_CP_OFF EQU H'3FFF'
_DATA_CP_ON EQU H'3EFF'
_DATA_CP_OFF EQU H'3FFF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FF7'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FFB'
_LVP_ON EQU H'3FFF'
_LVP_OFF EQU H'3F7F'
_MCLRE_ON EQU H'3FFF'
_MCLRE_OFF EQU H'3FDF'
_ER_OSC_CLKOUT EQU H'3FFF'
_ER_OSC_NOCLKOUT EQU H'3FFE'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_EXTCLK_OSC EQU H'3FEF'
_LP_OSC EQU H'3FEC'
_XT_OSC EQU H'3FED'
_HS_OSC EQU H'3FEE'
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _HS_OSC
TIMER1 EQU H'20'
TIMER2 EQU H'21'
BYTE EQU H'22'
COUNT1 EQU H'23'
COUNT2 EQU H'24'
BYTE2 EQU H'25'
ORG 0
GOTO RESET
DELAY MOVLW D'54'
MOVWF TIMER2
DEL_LOOP1 MOVLW D'60'
MOVWF TIMER1
DEL_LOOP2 DECFSZ TIMER1,F
GOTO DEL_LOOP2
DECFSZ TIMER2,F
GOTO DEL_LOOP1
RETURN
DELAY2; MOVLW D'1'
; MOVWF TIMER2
DEL_LOOP3 MOVLW D'1'
MOVWF TIMER1
DEL_LOOP4 DECFSZ TIMER1,F
GOTO DEL_LOOP4
; DECFSZ TIMER2,F
; GOTO DEL_LOOP3
RETURN
LCD_WRITE MOVWF PORTB
MOVLW B'00000001'
MOVWF PORTA
; CALL DELAY2
MOVLW H'02'
MOVWF PORTB
RLF BYTE,F
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
RLF BYTE,F
MOVF BYTE,W
ANDLW H'01'
MOVWF PORTB
IORLW H'02'
MOVWF PORTB
; CALL DELAY2
MOVLW B'00000011'
MOVWF PORTA
RETURN
; **********************************
; ** RESET : main boot routine **
; **********************************
RESET MOVLW B'00000111' ;Disable Comparator module's
MOVWF CMCON
;
BSF STATUS,RP0 ;Switch to register bank 1
;Disable pull-ups
;INT on rising edge
;TMR0 to CLKOUT
;TMR0 Incr low2high trans.
;Prescaler assign to Timer0
;Prescaler rate is 1:256
MOVLW B'11010111' ;Set PIC options (See datasheet).
MOVWF OPTION_REG ;Write the OPTION register.
;
CLRF INTCON ;Disable interrupts
MOVLW B'11000000'
MOVWF TRISB ;RB7 & RB6 are inputs.
;RB5...RB0 are outputs.
MOVLW B'11111100' ;all RA ports are inputs
MOVWF TRISA
BCF STATUS,RP0 ;Switch Back to reg. Bank 0
CLRF PORTB
;
MOVLW B'00000010'
MOVWF PORTA
; CALL DELAY
MOVLW H'FF'
MOVWF PORTB
; CALL DELAY
MOVLW H'00'
MOVWF PORTB
; CALL DELAY
MOVLW B'00000011'
MOVWF PORTA
; CALL DELAY
MOVLW H'00'
MOVWF BYTE2
; GOTO PHILIPS
MOVLW H'BB' ;COMSCN
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'01'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'D1' ;OSCON
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'94' ;SLPOUT
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'20' ;PWRCTR
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'0F'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'A7' ;DISINV
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'BC' ;DATCTL
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'03'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'00'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'01'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'CE' ;RGBSET8
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
GOTO RGB
PHILIPS MOVLW H'38' ;IDMOFF
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'11' ;SLPOUT
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'3A' ;COLMOD
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'02'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'25' ;SETCON
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'3E'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'23' ;DAL
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'36' ;MADCTL
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'88'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'2D' ;RGBSET8
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
RGB MOVLW H'00'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'02'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'04'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'06'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'08'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0A'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0C'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0E'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'00'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'02'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'04'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'06'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'08'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0A'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0C'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0E'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'00'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'04'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'08'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'0C'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
; MOVLW H'13' ;NORON (Philips)
; MOVWF BYTE
; MOVLW CMD
; CALL LCD_WRITE
MOVLW H'AF' ;DISON (Epson)
; MOVLW H'29' ;DISON (Philips)
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'75' ;PASET (Epson)
; MOVLW H'2B' ;PASET (Philips)
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'00'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'83'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'15' ;CASET (Epson)
; MOVLW H'2A' ;CASET (Philips)
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
MOVLW H'00'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
MOVLW H'83'
MOVWF BYTE
MOVLW DAT
CALL LCD_WRITE
REPEAT
MOVLW H'5C' ;RAMWR (Epson)
; MOVLW H'2C' ;RAMWR (Philips)
MOVWF BYTE
MOVLW CMD
CALL LCD_WRITE
; MOVLW H'00'
MOVF BYTE2,W
COMF BYTE2,F
MOVWF BYTE
MOVLW D'132'
MOVWF COUNT2
FILL_LOOP1 MOVLW D'132'
MOVWF COUNT1
FILL_LOOP2 MOVLW DAT
CALL LCD_WRITE
; INCF BYTE,F
DECFSZ COUNT1,F
GOTO FILL_LOOP2
; INCF BYTE,F
DECFSZ COUNT2,F
GOTO FILL_LOOP1
; MOVLW H'00'
; MOVWF PORTB
THE_END GOTO REPEAT
END