#include p16f690.inc
#include Adressage.inc
extern LCD_CLEAR,INITLCD,LCD_Position,LCD_Write,Cycle_Write,Conv_ASCII,LCD_Position
org 0x00
CMP equ 0x34
call INIT
call INITLCD
call LCD_CLEAR
movlw 0x00
call LCD_Position
bsf STATUS,RP0 ;bank 1
bcf STATUS,RP1
;bcf OPTION_REG,7 ; Enable the pull up
;bcf STATUS,RP0 ; en mettant les pin en entrée analogique active le pull up
;movlw 0xFF
;movwf ANSEL
bsf STATUS,RP0
bsf STATUS,RP1 ; Selection bank 3
movlw 0xF0 ;configuration du port
movwf TRISC
bcf STATUS,RP0
debut
movlw 0xFF ;
movwf PORTC
call Wait2s
bcf PORTC,Lin1 ;
call Wait2s
goto test_cols
Ligne2
bsf PORTC,Lin1
bcf PORTC,Lin2
call Wait2s
goto test_cols2
Ligne3
bsf PORTC,Lin2
bcf PORTC,Lin3
call Wait2s
goto test_cols3
Ligne4
bsf PORTC,Lin3
bcf PORTC,Lin4
call Wait2s
goto test_cols4
tout_à_1
bsf PORTC,Lin4
goto debut
Ecrire1
movlw '1'
call LCD_Write
goto debut
Ecrire2
movlw '2'
call LCD_Write
goto debut
Ecrire3
movlw '3'
call LCD_Write
goto debut
Ecrire4
movlw '4'
call LCD_Write
goto debut
Ecrire5
movlw '5'
call LCD_Write
goto debut
Ecrire6
movlw '6'
call LCD_Write
goto debut
Ecrire7
movlw '7'
call LCD_Write
goto debut
Ecrire8
movlw '8'
call LCD_Write
goto debut
Ecrire9
movlw '9'
call LCD_Write
goto debut
Ecrire0
movlw '0'
call LCD_Write
goto debut
dep_cur_droit
addlw 0x02
call LCD_Position
goto debut
dep_cur_gauche
sublw 0x01
call LCD_Position
goto debut
dep_cur_haut
addlw 0x40
call LCD_Position
goto debut
dep_cur_bas
sublw 0x40
call LCD_Position
goto debut
test_cols
btfss PORTC,Col1
goto Ecrire1
;btfss PORTC,Col2
;goto Ecrire2
btfss PORTC,Col4
goto dep_cur_droit
btfss PORTC,Col3
goto Ecrire3
btfsc PORTC,Col3
goto Ligne2
test_cols2
btfss PORTC,Col1
goto Ecrire4
;btfss PORTC,Col2
;goto Ecrire5
btfss PORTC,Col4
goto dep_cur_gauche
btfss PORTC,Col3
goto Ecrire6
btfsc PORTC,Col3
goto Ligne3
test_cols3
btfss PORTC,Col1
goto Ecrire7
;btfss PORTC,Col2
;goto Ecrire8
btfss PORTC,Col4
goto dep_cur_haut
btfss PORTC,Col3
goto Ecrire9
btfsc PORTC,Col3
goto Ligne4
test_cols4
;btfss PORTC,Col2
;call Ecrire0
;btfsc PORTC,Col2
btfss PORTC,Col4
goto dep_cur_bas
goto tout_à_1
Fin
goto Fin
; ------------------------ INIT
INIT
bcf STATUS,RP0
bcf STATUS,RP1 ; Selection bank
clrf PORTA ; init PORTA
clrf PORTB ; Init PORTB
clrf PORTC ; Init PORTC
bsf STATUS,RP0
bsf STATUS,RP1 ; Selection bank 3
movlw 0x00 ;Parametrage PORTA
movwf TRISA
movlw 0x00 ; Parametrage PORTB 0x_0
movwf TRISB
movlw 0xF0 ; Parametrage PORTC 0xF_
movwf TRISC
bcf STATUS,RP0 ; Bank 2
clrf ANSEL
clrf ANSELH
bcf STATUS,RP1
return
Ecrire
movlw '*'
call LCD_Write
movlw 0x43
call LCD_Write
return
Wait2s
movlw 0xFF
movwf CMP
loop nop
nop
nop
nop
nop ;1u
decfsz CMP,1 ;1us 2 si CMP=0
goto loop ;3us
return
end