Hi all
I am trying to use a PIC16F913 to read a keypad, the problem is i can not get PortC.2 to go to a high state ,can anyone please point me in a direction, Pin 0 and 1 works fine
Code:
INCLUDE "MODEDEFS.BAS"
Asm
ERRORLEVEL -306
Endasm
DEFINE OSC 20 ' Define crystal as 20Mhz
LCDCON = 0
TRISC = %11110000 'Set PORTC for keypad
TRISB = %00000000 'Sert PORTb as outputs and for use with the ICD2
VAR1 VAR BYTE
VALUE VAR BYTE
PortB.0 = 0
keyPad: portc=1
if portc.4=1 then
for VAR1=0 to 10
if portc.4=1 then VAR1 = 0
next
VALUE=1
goto getPin
endif
if portc.5=1 then
for VAR1=0 to 10
if portc.5=1 then VAR1 = 0
next
VALUE=4
goto getPin
endif
if portc.6=1 then
for VAR1=0 to 10
if portc.6=1 then VAR1 = 0
next
VALUE=7
goto getPin
endif
if portc.7=1 then
for VAR1=0 to 10
if portc.7=1 then VAR1 = 0
next
VALUE=10 '* button
goto getPin
endif
portc=2
if portc.4=1 then
for VAR1=0 to 10
if portc.4=1 then VAR1 = 0
next
VALUE=2
goto getPin
endif
if portc.5=1 then
for VAR1=0 to 10
if portc.5=1 then VAR1 = 0
next
VALUE=5
goto getPin
endif
if portc.6=1 then
for VAR1=0 to 10
if portc.6=1 then VAR1 = 0
next
VALUE=8
goto getPin
endif
if portc.7=1 then
for VAR1=0 to 10
if portc.7=1 then VAR1 = 0
next
VALUE=0
goto getPin
endif
portc=4
if portc.4=1 then
for VAR1=0 to 10
if portc.4=1 then VAR1 = 0
next
VALUE=3
goto getPin
endif
if portc.5=1 then
for VAR1=0 to 10
if portc.5=1 then VAR1 = 0
next
VALUE=6
goto getPin
endif
if portc.6=1 then
for VAR1=0 to 10
if portc.6=1 then VAR1 = 0
next
VALUE=9
goto getPin
endif
if portc.7=1 then
for VAR1=0 to 10
if portc.7=1 then VAR1 = 0
next
VALUE=11 '# button
goto getPin
endif
goto keypad
getpin:
PortB.0 = 1
return
END
Bookmarks