Hi All ,
i have written a program to control my keyboard through a PIC16f877 , using MikroBasic which has a library inside it called ps2.
my problem is the pic doesn't feel with the ps2 , i don't where is the trouble ,
my program is here :
dim
keydata as byte
special as byte
down as byte
INTCON = 0 ' Disable all interrupts
Ps2_Config(PORTC, 0, 1)
Delay_ms(100) ' Wait for keyboard to finish
'TRISA=0
TRISE=0
'PORTA=%000000000
PORTE=%000000000
main:
PORTE.1=1
DELAY_MS(1000)
if Ps2_Key_Read(keydata, special, down) = 1 then
if (keydata = 13) and (special = 1) then
PORTE.0=1
DELAY_MS(1000)
PORTE.0=0
PORTE.2=1
Delay_ms(1000)
PORTE.2=0
else
Delay_ms(50)
end if
Delay_ms(50)
end if
Delay_ms(50)
PORTE.1=0
DELAY_MS(1000)
Goto main
end.
i haven't connected the pin 4 and 6 because they are NC in the ps2 socket , is it correct ?
thank you
i have written a program to control my keyboard through a PIC16f877 , using MikroBasic which has a library inside it called ps2.
my problem is the pic doesn't feel with the ps2 , i don't where is the trouble ,
my program is here :
dim
keydata as byte
special as byte
down as byte
INTCON = 0 ' Disable all interrupts
Ps2_Config(PORTC, 0, 1)
Delay_ms(100) ' Wait for keyboard to finish
'TRISA=0
TRISE=0
'PORTA=%000000000
PORTE=%000000000
main:
PORTE.1=1
DELAY_MS(1000)
if Ps2_Key_Read(keydata, special, down) = 1 then
if (keydata = 13) and (special = 1) then
PORTE.0=1
DELAY_MS(1000)
PORTE.0=0
PORTE.2=1
Delay_ms(1000)
PORTE.2=0
else
Delay_ms(50)
end if
Delay_ms(50)
end if
Delay_ms(50)
PORTE.1=0
DELAY_MS(1000)
Goto main
end.
i haven't connected the pin 4 and 6 because they are NC in the ps2 socket , is it correct ?
thank you