the circuit is connectes in a 4 bit basis and
the 4 upper bit DB4B7 (pin11 to pin14), of the LCD are connected to
the 4 upper bit RB4:RB7 (pin10 to pin13) of the PIC 16F628
A2= R/W, A1=R/S, A0=E
........................................
problem: the program instead to write "control-12" write only blanks.
.......................................
;writing "control 12" on the LCD screen
list p=16F628A
#include <p16F628A.inc>
errorlevel -302, -207
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_ON & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _XT_OSC
;...................
#define status STATUS
#define option_reg OPTION_REG
#define intcon INTCON
#define Banco0 bcf status,5
#define Banco1 bsf status,5
#define portb PORTB
#define TrisB TRISB
#define Trisb TRISB
#define trisb TRISB
#define Trisa TRISA
#define tmr1h TMR1H
#define tmr1l TMR1L
#define tmr1on bsf T1CON,0
#define tmr1off bcf T1CON,0
#define pir1 PIR1
#define t1con T1CON
#define tmr1ie TMR1IE
#define porta PORTA
#define trisa TRISA
#define vrcon VRCON
#define cmcon CMCON
no equ 0x26
no2 equ 0x28
;....................
org 0x0000 ; para...
movlw 0x07 ; cerrar....
movwf cmcon ; el comparador
;....................
definiciones:
Banco1
clrf trisb
clrf trisa
clrf no
Banco0
;.....................arranque del Lcd
step1: call delay ;must be 15 mseg
step2: movlw 0x30 ;B'00110000';must be 4.1mseg, function set
call iniloop
step3: movlw 0x30 ;B'00110000';must be 100useg
call iniloop
step4: movlw 0x30 ;B'00110000', must be 100useg
call iniloop
step5: movlw 0x02 ;B'00100000', definition for 4bits address lines must be 100useg
call iniloop
step6: movlw 0x20 ;B'0010',function set=4bits must be 53useg
call iniloop
step6b: movlw 0x80 ;B'1000', , 2lines, 5x7
call iniloop
step7: movlw 0x00 ;B='0000' display on/off
call iniloop
step7b: movlw 0x80 ;B'1000', , display, cursor & blinking= off
call iniloop
step8: movlw 0x00 ;B'0000', , clear display
call iniloop
step8b: movlw 0x10 ;B'0001', , clear display
call iniloop
step9: movlw 0x00 ;B'0000', ,entry mode set
call iniloop
step9b: movlw 0x60 ;B'0110', , increment cursor, no display shift
call iniloop
;(step 10)....................initializations ends
step11: movlw 0x00 ;B'0000', , turning on the display
call iniloop
step11b: movlw 0x60 ;B'1110', , display=on, cursor= on, blinking=off
call iniloop
goto programa
iniloop: movwf portb
;movlw 0x00 ;
;movwf porta ;r/s= 0, r/w=0
movlw 0x01
movwf porta ;e=1
call delay
movlw 0x00
movwf porta ;e=0
return
programa: movlw 0xC0 ;DD Ram= C0
call inst
movlw 0x10
call inst
programa2: movlw 0x44 ;C
call datos
movlw 0x33
call datos
movlw 0x44 ;O
call datos
movlw 0xFF
call datos
movlw 0x44 ;N
call datos
movlw 0xEE
call datos
movlw 0x55 ;T
call datos
movlw 0x44
call datos
movlw 0x55 ;R
call datos
movlw 0x22
call datos
movlw 0x44 ;O
call datos
movlw 0xFF
call datos
movlw 0x44 ;L
call datos
movlw 0xCC
call datos
movlw 0x22 ;-
call datos
movlw 0xDD
call datos
movlw 0x33 ;1
call datos
movlw 0x11
call datos
movlw 0x33 ;2
call datos
movlw 0x22
call datos
goto programa2
inst: movwf portb
;movlw 0x00 ;
;movwf porta ;r/w= 0, r/s=0,e=0
movlw 0x01
movwf porta ;e=1
call delay
movlw 0x00
movwf porta ;e=0
call delay
return
datos: movwf portb
;movlw 0x02 ;
;movwf porta ; r/w=0, r/s= 1, e=0; data, write
movlw 0x03
movwf porta ;e=1
call delay
movlw 0x02
movwf porta ;e=0
call delay
return
delay: bsf t1con,0 ;timer 1 on
loop: nop
btfss pir1,0 ;flag overflow tmr1 on?
goto loop
bcf pir1,0 ;switch off tmr1 flag
return
end
the 4 upper bit DB4B7 (pin11 to pin14), of the LCD are connected to
the 4 upper bit RB4:RB7 (pin10 to pin13) of the PIC 16F628
A2= R/W, A1=R/S, A0=E
........................................
problem: the program instead to write "control-12" write only blanks.
.......................................
;writing "control 12" on the LCD screen
list p=16F628A
#include <p16F628A.inc>
errorlevel -302, -207
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_ON & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _XT_OSC
;...................
#define status STATUS
#define option_reg OPTION_REG
#define intcon INTCON
#define Banco0 bcf status,5
#define Banco1 bsf status,5
#define portb PORTB
#define TrisB TRISB
#define Trisb TRISB
#define trisb TRISB
#define Trisa TRISA
#define tmr1h TMR1H
#define tmr1l TMR1L
#define tmr1on bsf T1CON,0
#define tmr1off bcf T1CON,0
#define pir1 PIR1
#define t1con T1CON
#define tmr1ie TMR1IE
#define porta PORTA
#define trisa TRISA
#define vrcon VRCON
#define cmcon CMCON
no equ 0x26
no2 equ 0x28
;....................
org 0x0000 ; para...
movlw 0x07 ; cerrar....
movwf cmcon ; el comparador
;....................
definiciones:
Banco1
clrf trisb
clrf trisa
clrf no
Banco0
;.....................arranque del Lcd
step1: call delay ;must be 15 mseg
step2: movlw 0x30 ;B'00110000';must be 4.1mseg, function set
call iniloop
step3: movlw 0x30 ;B'00110000';must be 100useg
call iniloop
step4: movlw 0x30 ;B'00110000', must be 100useg
call iniloop
step5: movlw 0x02 ;B'00100000', definition for 4bits address lines must be 100useg
call iniloop
step6: movlw 0x20 ;B'0010',function set=4bits must be 53useg
call iniloop
step6b: movlw 0x80 ;B'1000', , 2lines, 5x7
call iniloop
step7: movlw 0x00 ;B='0000' display on/off
call iniloop
step7b: movlw 0x80 ;B'1000', , display, cursor & blinking= off
call iniloop
step8: movlw 0x00 ;B'0000', , clear display
call iniloop
step8b: movlw 0x10 ;B'0001', , clear display
call iniloop
step9: movlw 0x00 ;B'0000', ,entry mode set
call iniloop
step9b: movlw 0x60 ;B'0110', , increment cursor, no display shift
call iniloop
;(step 10)....................initializations ends
step11: movlw 0x00 ;B'0000', , turning on the display
call iniloop
step11b: movlw 0x60 ;B'1110', , display=on, cursor= on, blinking=off
call iniloop
goto programa
iniloop: movwf portb
;movlw 0x00 ;
;movwf porta ;r/s= 0, r/w=0
movlw 0x01
movwf porta ;e=1
call delay
movlw 0x00
movwf porta ;e=0
return
programa: movlw 0xC0 ;DD Ram= C0
call inst
movlw 0x10
call inst
programa2: movlw 0x44 ;C
call datos
movlw 0x33
call datos
movlw 0x44 ;O
call datos
movlw 0xFF
call datos
movlw 0x44 ;N
call datos
movlw 0xEE
call datos
movlw 0x55 ;T
call datos
movlw 0x44
call datos
movlw 0x55 ;R
call datos
movlw 0x22
call datos
movlw 0x44 ;O
call datos
movlw 0xFF
call datos
movlw 0x44 ;L
call datos
movlw 0xCC
call datos
movlw 0x22 ;-
call datos
movlw 0xDD
call datos
movlw 0x33 ;1
call datos
movlw 0x11
call datos
movlw 0x33 ;2
call datos
movlw 0x22
call datos
goto programa2
inst: movwf portb
;movlw 0x00 ;
;movwf porta ;r/w= 0, r/s=0,e=0
movlw 0x01
movwf porta ;e=1
call delay
movlw 0x00
movwf porta ;e=0
call delay
return
datos: movwf portb
;movlw 0x02 ;
;movwf porta ; r/w=0, r/s= 1, e=0; data, write
movlw 0x03
movwf porta ;e=1
call delay
movlw 0x02
movwf porta ;e=0
call delay
return
delay: bsf t1con,0 ;timer 1 on
loop: nop
btfss pir1,0 ;flag overflow tmr1 on?
goto loop
bcf pir1,0 ;switch off tmr1 flag
return
end