mpardinho
Newbie level 5
i use this code but then i compile occurs some errors
i help me with erros
DataPin equ 0x06 ;PIC Pin
ClockPin equ 0x07 ;PIC Pin
Char equ 0x35 ;buffer
BitCounter equ 0x36 ;number of bits to read
GetScanCode
bsf STATUS, RP0 ;select bank 1
bsf TRISB, DataPin ;set pins as input
bsf TRISB, ClockPin
bcf OPTION_REG, NOT_RBPU ;pull-ups are enabled
bcf STATUS, RP0 ;select bank 0
call ClockWait ;wait for Pull up to take effect and keyboard to pull clock low
;--- Read Data Bits ----
ReadKey
clrf Char ERROR
movlw .8 ;bits to read
movwf BitCounter
ReadChar
rrf Char ERROR
bcf Char, 7 ;default value is 0
call ClockWait ;wait for clock to go high then low
btfss PORTB, DataPin ;read Data
goto Next ERROR
bsf Char, 7 ;Data is High ERROR
Next decfsz BitCounter
goto ReadChar ;read next Data Bit
call ClockWait ;Parity Bit
call ClockWait ;Stop Bit
;Pull Clock Line Low (keyboard will buffer any further keystrokes)
bsf STATUS, RP0 ;select bank 1
bcf TRISB, ClockPin ;set clock line as output
bcf STATUS, RP0 ;select bank 0
bcf PORTB, ClockPin ;set clock line low
movf Char, W
return
ClockWait
;wait for clock to go high
btfss PORTB, ClockPin
goto ClockWait
ClockWait2
;wait for clock to go low
btfsc PORTB, ClockPin
goto ClockWait2
return ERROR
i help me with erros
DataPin equ 0x06 ;PIC Pin
ClockPin equ 0x07 ;PIC Pin
Char equ 0x35 ;buffer
BitCounter equ 0x36 ;number of bits to read
GetScanCode
bsf STATUS, RP0 ;select bank 1
bsf TRISB, DataPin ;set pins as input
bsf TRISB, ClockPin
bcf OPTION_REG, NOT_RBPU ;pull-ups are enabled
bcf STATUS, RP0 ;select bank 0
call ClockWait ;wait for Pull up to take effect and keyboard to pull clock low
;--- Read Data Bits ----
ReadKey
clrf Char ERROR
movlw .8 ;bits to read
movwf BitCounter
ReadChar
rrf Char ERROR
bcf Char, 7 ;default value is 0
call ClockWait ;wait for clock to go high then low
btfss PORTB, DataPin ;read Data
goto Next ERROR
bsf Char, 7 ;Data is High ERROR
Next decfsz BitCounter
goto ReadChar ;read next Data Bit
call ClockWait ;Parity Bit
call ClockWait ;Stop Bit
;Pull Clock Line Low (keyboard will buffer any further keystrokes)
bsf STATUS, RP0 ;select bank 1
bcf TRISB, ClockPin ;set clock line as output
bcf STATUS, RP0 ;select bank 0
bcf PORTB, ClockPin ;set clock line low
movf Char, W
return
ClockWait
;wait for clock to go high
btfss PORTB, ClockPin
goto ClockWait
ClockWait2
;wait for clock to go low
btfsc PORTB, ClockPin
goto ClockWait2
return ERROR