Sending Commands to Keyboard from PIC 18F452

Status
Not open for further replies.

designer

Newbie level 4
Joined
Nov 4, 2003
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
85
18f452 keyboard

i am corrently interfacing keyboard to pic 18f452. when command to turn on 'caps/num' is given to the kbd, the keyboard hangs .

Host to Keyboard code is as follows

void SendKbdCmd(unsigned char cmd)
{
unsigned char cnt, par=0, mask=0x1;

INTCONbits.GIE = 0;
KbXmit=1;
while(!kbdClk);
TRISKbdClk = 0;
kbdClk=0;
Delay10TCYx(25);
TRISKbdDat = 0;
kbdDat=0;
TRISKbdClk = 1;
while(kbdClk);
for(cnt=0; cnt<8; cnt++)
{
if(cmd&mask)
{
par++;
kbdDat=1;
}
else
kbdDat=0;
mask<<=1;
while(!kbdClk);
while(kbdClk);
}
kbdDat=!(par%2);
while(!kbdClk);
TRISKbdDat = 1;
while(kbdClk);
INTCON3bits.INT1IF=0;
INTCONbits.GIE = 1;
}
 

go to h**p://www.beyondlogic.org
They have a couple of articles on interfacing to a pc keyboard. Might help?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…