I have been trying to implement a software initialization
on a character LCD using a PIC 16f690.
When I run the code as is the display will not display anything.
If I jump over the initialization sequence I have written and go
straight to writing instructions it seems to work fine. (automatic
initialization works fine with the power supply/test circuit at present).
A couple of notes about the display.
OPTREX DMC20261NY-LY
Hitachi 44780 chip
Although unit is previously unused, it may be an older model.
Any ideas? I have changed the delays longer and shorter in
an attempt to see if it was a timing issue.
Datasheet attached.
on a character LCD using a PIC 16f690.
When I run the code as is the display will not display anything.
If I jump over the initialization sequence I have written and go
straight to writing instructions it seems to work fine. (automatic
initialization works fine with the power supply/test circuit at present).
A couple of notes about the display.
OPTREX DMC20261NY-LY
Hitachi 44780 chip
Although unit is previously unused, it may be an older model.
Any ideas? I have changed the delays longer and shorter in
an attempt to see if it was a timing issue.
Datasheet attached.
Rich (BB code):
;Internal Oscillator 4MHz (1Mhz instruction)
;PIN CONNECTIONS:
;______________
;PIC LCD
;______________
;RB4 RS
;RB5 R/W
;RB6 ENABLE
;RC0-RC7 DB0-DB7
;****BEGIN INITIALIZE LCD****
;DWELL 100ms (Wait for 15ms minimum after Vcc=4.5V)
MOVLW 0xDF ;223
MOVWF DWELLA
MOVLW 0x82 ;130
MOVWF DWELLB
DECFSZ DWELLA,F
GOTO $-1
DECFSZ DWELLB,F
GOTO $-3
NOP
NOP
;FUNCTION SET COMMAND (8-BIT INTERFACE)*1*
MOVLW 0x30 ;0011 0000
MOVWF PORTC ;0011 0000 RC5(DB5)=1 RC4(DB4)=1
MOVLW 0x00 ;0000 0000
MOVWF PORTB ;0000 0000 RB4(RS)=0 RB5(R/W)=0 RB6(E)=0
NOP ;WAIT MINIMUM .14uS
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;FUNCTION SET COMMAND (8-BIT INTERFACE)*2*
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;FUNCTION SET COMMAND (8-BIT INTERFACE)*3*
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;FUNCTION SET COMMAND (8-BIT INTERFACE, LINES 2, FONT 5X7)
MOVLW 0x38 ;0011 1000
MOVWF PORTC ;0011 1000 RC5=1 RC4=1 RC3=1 RC2=0
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;DISPLAY OFF
MOVLW 0x08 ;0000 1000
MOVWF PORTC ;0000 1000 RC3=1 (DISPLAY OFF)
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;****END INITIALIZE LCD****
;***************************
;NO INITIALIZATION JUMP TO HERE
;***************************
;CLEAR DISPLAY
MOVLW 0x01 ;0000 0001
MOVWF PORTC ;0000 0001 RC0=1
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;SET ENTRY MODE (INCREMENT, NO DISPLAY SHIFT)
MOVLW 0x06 ;0000 0110
MOVWF PORTC ;0000 0110 RC2=1 RC1=1 RC0=0
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;DISPLAY ON OFF CONTROL (DISPLAY=ON, CURSOR=ON, BLINK=ON)
MOVLW 0x0E ;0000 1110
MOVWF PORTC ;0000 1110 RC3=1 RC1=2 RC1=1 RC0=0
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;CLEAR DISPLAY AND CURSOR HOME
MOVLW 0x01 ;0000 0001
MOVWF PORTC ;0000 0001 RC0=1
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;****END INITIALIZE LCD****
;TEST WRITE CHARACTER
;CHARACTER 1
;INSTRUCTION SET DD RAM ADDRESS
MOVLW 0x8A ;1000 1010 ADDRESS 0Ah
MOVWF PORTC ;1000 1010 ADDRESS 0Ah
MOVLW 0x00 ;0000 0000
MOVWF PORTB ;0000 0000 RB4(RS)=0 RB5(R/W)=0 RB6(E)=0
NOP ;WAIT MINIMUM .14uS
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
;WRITE DATA
MOVLW 0x41 ;0100 0001
MOVWF PORTC ;0100 0001 CHARACTER=A
MOVLW 0x10 ;0001 0000
MOVWF PORTB ;0001 0000 RB4(RS)=1 RB5(R/W)=0 RB6(E)=0
NOP ;WAIT MINIMUM .14uS
BSF PORTB,6 ;x1xx xxxx RB6(E)=1 (ENABLE HIGH)
NOP ;WAIT 1us
NOP ;WAIT 1us
BCF PORTB,6 ;x0xx xxxx RB6(E)=0 (ENABLE LOW)
CALL DWELL5ms
HERE
NOP
GOTO HERE
DWELL5ms
;DWELL 5ms
MOVLW 0x7E ;126
MOVWF DWELLA
MOVLW 0x07 ;7
MOVWF DWELLB
DECFSZ DWELLA,F
GOTO $-1
DECFSZ DWELLB,F
GOTO $-3
NOP
NOP
RETURN
Attachments
-
201.5 KB Views: 23
Last edited: