Im interfacing a 16c84 with a AT keyboard I have it receiving the keyboard scan code and parity bit fine.
I now want to check the parity bit for correctness. I'm currently iqnoring it
The way I understand odd parity is counts all the one in a byte and makes the parity a 0 or 1 to make the byte and the parity bit have a odd number of ones
I also plan on sending keyboard scan codes to the computer.
So Im hoping one of you guys that is better at software than I can show me how to check and generate a parity bit from a byte
___________________________
This message was ported from CCS's old forum
Original Post ID: 1299
Tomi Guest
Re: Checking a byte for odd parity
Posted: Fri Nov 23, 2001 1:02 pm
Try this:
char GetParity(char be)
{
be ^= be >> 4;
be ^= be >> 2;
be ^= be >> 1;
be &= 0x01;
return (be);
}
Output: 0->Even, 1->Odd
:=Im interfacing a 16c84 with a AT keyboard I have it receiving the keyboard scan code and parity bit fine.
:=
:=I now want to check the parity bit for correctness. I'm currently iqnoring it
:=
:=The way I understand odd parity is counts all the one in a byte and makes the parity a 0 or 1 to make the byte and the parity bit have a odd number of ones
:=
:=I also plan on sending keyboard scan codes to the computer.
:=
:=So Im hoping one of you guys that is better at software than I can show me how to check and generate a parity bit from a byte
___________________________
This message was ported from CCS's old forum
Original Post ID: 1302
Snowblind Guest
Re: Checking a byte for odd parity
Posted: Fri Nov 23, 2001 3:24 pm
Thank you,
Works great I had to add a line to get the output i wanted
after this line be &= 0x01; I put a be ^= 0x01;
You me past the bit shifting i have problems getting that down
:=Try this:
:=
:=char GetParity(char be)
:={
:=be ^= be >> 4;
:=be ^= be >> 2;
:=be ^= be >> 1;
:=be &= 0x01;
:=return (be);
:=}
:=
:=Output: 0->Even, 1->Odd
:=
:=
:=:=Im interfacing a 16c84 with a AT keyboard I have it receiving the keyboard scan code and parity bit fine.
:=:=
:=:=I now want to check the parity bit for correctness. I'm currently iqnoring it
:=:=
:=:=The way I understand odd parity is counts all the one in a byte and makes the parity a 0 or 1 to make the byte and the parity bit have a odd number of ones
:=:=
:=:=I also plan on sending keyboard scan codes to the computer.
:=:=
:=:=So Im hoping one of you guys that is better at software than I can show me how to check and generate a parity bit from a byte
___________________________
This message was ported from CCS's old forum
Original Post ID: 1308
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum