I swap the :
LcdE equ 0 ; enable Lcd
LcdRw equ 3 ; read Lcd
with this
LcdE equ 3 ; read Lcd
LcdRw equ 0 ; enable Lcd
but the below code isn't work
Before swap the code work
LcdE equ 0 ; enable Lcd
LcdRw equ 3 ; read Lcd
with this
LcdE equ 3 ; read Lcd
LcdRw equ 0 ; enable Lcd
but the below code isn't work
Before swap the code work
Code:
;**************************************************************
;* PORTB: 0 LCD Display E
;* 1
;* 2 LCD Display RS
;* 3 LCD Display R/W
;* 4-7 LCD Display D4 .. D7
PORTC equ PORTB ; LCD-Control-Port
PORTD equ PORTB ; LCD-Daten-Port
LcdE equ 0 ; enable Lcd
LcdRw equ 3 ; read Lcd
LcdRs equ 2 ; Data Lcd (not control)
;********************************************************
; The program begins with the initialization
Init bsf STATUS, RP0 ; Bank 1
movlw B'00000000' ; PortB all outputs
movwf TRISB
bcf STATUS, RP0 ; Bank 0
call InitLCD ; Display initialization
;*****************************************************************
;around loops * 1 ms
;10MHz -> 2,5MHz -> 2500T
WAIT
top movlw .249 ; timing adjustment variable (1ms) 10MHz 249*10=2490T
movwf loops2
top2 nop ; sit and wait (Schleifenlδnge 10T)
nop
nop
nop
nop
nop
nop
decfsz loops2, F ; internal loops complete?
goto top2 ; no, go again
;
decfsz loops, F ; more outer loops complete?
goto top ; no, go again
retlw 0 ; yes, return from subWAIT
;**************************************************************
; LCD-Routinen
;
; initialization the LCD-Displays
InitLCD
movlw D'255' ; 250 ms Break after switching on
movwf loops
call WAIT
movlw B'00110000' ; 1
movwf PORTB
bsf PORTB, LcdE
nop
bcf PORTB, LcdE
movlw D'50' ; 50 ms Pause
movwf loops
call WAIT
movlw B'00110000' ; 2
call Control8Bit
movlw B'00110000' ; 3
call Control8Bit
movlw B'00100000' ; 4
call Control8Bit
movlw B'00000001' ; lφschen and cusor home
call OutLcdControl
movlw B'00101000' ; 5 function set, 4-bit 2-lined, 5x7
call OutLcdControl
movlw B'00001000' ; 6 display off
call OutLcdControl
movlw B'00000110' ; 7 entry mode, increment, disable display-shift
call OutLcdControl
movlw B'00000011' ; 8 cursor home, cursor home
call OutLcdControl
movlw B'00001100' ; 9 display on, cursor off, cursor flash off
call OutLcdControl
return
; a control byte 8-bit upper-carry
Control8Bit
movwf PORTB
bsf PORTB, LcdE
nop
bcf PORTB, LcdE
movlw D'10'
movwf loops
call WAIT
return
; for it wait, there? the display for the data acceptance is ready
LcdBusy
bsf STATUS, RP0 ; make Port B4..7 input
movlw B'11110000'
iorwf TRISB, f
bcf STATUS, RP0
BusyLoop
bcf PORTC, LcdRs
bsf PORTC, LcdRw ; Lesen
bsf PORTC, LcdE
nop
movf PORTD, w
movwf LcdStatus
bcf PORTC, LcdE
nop
bsf PORTC, LcdE ; Enable
nop
bcf PORTC, LcdE
btfsc LcdStatus, 7 ; test bit 7
goto BusyLoop
bcf PORTC, LcdRw
bsf STATUS, RP0 ; make Port B4..7 output
movlw B'00001111'
andwf TRISB, f
bcf STATUS, RP0
return
; a byte with tax data from LCD data to the display upper-carry
OutLcdControl
movwf LcdDaten
call LcdBusy
movf LcdDaten, w
andlw H'F0'
movwf PORTD ; Hi-teil data write
bsf PORTC, LcdE
nop
bcf PORTC, LcdE ; Disable LcdBus
swapf LcdDaten, w
andlw H'F0'
movwf PORTD ; Lo-teil data write
bsf PORTC, LcdE
nop
bcf PORTC, LcdE ; Disable LcdBus
return
; a data byte of LCD upper-carry data to the display
OutLcdDaten
movwf LcdDaten
call LcdBusy
movf LcdDaten, w
andlw H'F0'
movwf PORTD ; Hi-teil data write
bsf PORTC, LcdRs ; Daten
bsf PORTC, LcdE ; Enable LcdBus
nop
bcf PORTC, LcdE ; Disable LcdBus
swapf LcdDaten, w
andlw H'F0'
movwf PORTD ; Lo-teil data write
bsf PORTC, LcdRs ; Daten
bsf PORTC, LcdE
nop
bcf PORTC, LcdE ; Disable LcdBus
bcf PORTC, LcdRs ;
return