here is the code for the right controller if i try to add something to write on the left controller i can't:
list p=16f877
#include <p16f877.inc>
LCD_DATA EQU PORTC ; LCD data lines interface
LCD_DATA_TRIS EQU TRISC
LCD_CTRL EQU PORTA ; LCD control lines interface
LCD_TEMP EQU 0x020 ; LCD subroutines internal use
R1 EQU 0x21
R2 EQU 0x22
DELAY EQU 0x023 ; Used in DELAYxxx routines
X_DELAY EQU 0x024 ; Used in X_DELAYxxx routines
; PORTA control bits
LCD_E EQU 2 ; LCD Enable control line
LCD_RW EQU 1 ; LCD Read/Write control line
LCD_RS EQU 0 ; LCD Register-Select control line
CS1 EQU 3
CS2 EQU 4
Rst EQU 5
ORG 0X00
GOTO main
main BCF STATUS,RP1 ;turns to Bank 1
BSF STATUS,RP0
MOVLW 0x06 ; Configure all pins
MOVWF ADCON1 ; as digital inputs BSF STATUS,RP0
MOVLW B'00000111'
OPTION
CLRF TRISA
MOVLW H'00'
MOVWF TRISC
BCF STATUS,RP0
CLRF PORTA
CLRF PORTC
BSF LCD_CTRL, LCD_RS ; Set LCD in command
BSF PORTA,5
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CALL DELAI
CALL DELAI
BCF PORTA,5
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
CALL DELAI
BSF PORTA,5
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
CALL DELAI
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
MOVLW H'07'
CALL WRITE_COMMAND1
MOVLW H'40' ;Set Y Column Address >From 0
CALL WRITE_COMMAND1
MOVLW H'B8' ;Set Page From 0
CALL WRITE_COMMAND1
MOVLW H'C0' ;Set Display Start Line
CALL WRITE_COMMAND1
MOVLW H'3F' ;Set Display ON
CALL WRITE_COMMAND1
SHOWC: CLRF R1
CLRF R2
SCLOOP1:
MOVLW H'B8' ;Set Page Address FROM 00H
ADDWF R1,W ;Command B8H~BFH
CALL WRITE_COMMAND1
; CALL WRITE_COMMAND2
MOVLW 0x40 ;Set Column Address FROM 40H
CALL WRITE_COMMAND1
; CALL WRITE_COMMAND2
SCLOOP2 CALL table
CALL WRITE_DATA1
INCF R2,1
MOVLW D'15'
SUBWF R2,W
BTFSC STATUS,Z
GOTO clea
GOTO SCLOOP2
clea CLRF R2
clearing INCF R2,1
MOVLW H'FF'
CALL WRITE_DATA1
MOVLW D'45'
SUBWF R2,W
BTFSC STATUS,Z
GOTO finale
GOTO clearing
table MOVF R2,W
ADDWF PCL,1
RETLW H'8C'
RETLW H'92'
RETLW H'92'
RETLW H'62'
RETLW H'80'
RETLW H'FE'
RETLW H'92'
RETLW H'92'
RETLW H'92'
RETLW H'80'
RETLW H'8C'
RETLW H'92'
RETLW H'92'
RETLW H'62'
RETLW H'00'
WRITE_COMMAND1 MOVWF LCD_TEMP ; Command to send is in W ;Write Command To CS1
BCF LCD_CTRL,CS2
BSF LCD_CTRL,CS1
BCF LCD_CTRL, LCD_RW ; Set LCD in read mode
BCF LCD_CTRL, LCD_RS ; Set LCD in command mode
MOVF LCD_TEMP, W
MOVWF LCD_DATA
BSF LCD_CTRL, LCD_E ; LCD E-line High
NOP
NOP
NOP
NOP
CALL DELAI
BCF LCD_CTRL, LCD_E ; LCD E-line Low
RETURN
;******************************************************************************
WRITE_DATA1
MOVWF LCD_TEMP ; Command to send is in W ;Write Command To CS1
BCF LCD_CTRL,CS2
BSF LCD_CTRL,CS1
BCF LCD_CTRL, LCD_RW ; Set LCD in read mode
BSF LCD_CTRL, LCD_RS ; Set LCD in command mode
MOVF LCD_TEMP, W
MOVWF LCD_DATA
BSF LCD_CTRL, LCD_E ; LCD E-line High
NOP
CALL DELAI
BCF LCD_CTRL, LCD_E ; LCD E-line Low
RETURN
;******************************************************************************
WRITE_COMMAND2
MOVWF LCD_TEMP ; Command to send is in W
BCF LCD_CTRL,CS1 ;Write Command To CS1
BSF LCD_CTRL,CS2
BCF LCD_CTRL, LCD_RW ; Set LCD in read mode
BCF LCD_CTRL, LCD_RS ; Set LCD in command mode
MOVF LCD_TEMP, W
MOVWF LCD_DATA
BSF LCD_CTRL, LCD_E ; LCD E-line High
NOP
CALL DELAI
BCF LCD_CTRL, LCD_E ; LCD E-line Low
RETURN
;******************************************************************************
DELAI MOVLW D'255'
MOVWF DELAY
REPEAT DECFSZ DELAY,1
GOTO REPEAT
RETURN
;LCDINIT
; Busy-flag is not yet valid
; CLRF LCD_CTRL ; ALL PORT output should output Low.
; power-up delay
; MOVLW 0x050
; CALL X_DELAY500
; MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x009
; CALL X_DELAY500
; MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;CALL X_DELAY500
; MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x030 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x008 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x001 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
;MOVLW 0x007 ; 8-bit-interface, 2-lines
; CALL LCDPUTCMD
finale NOP
END
|