CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Checking a byte for odd parity

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Snowblind
Guest







Checking a byte for odd parity
PostPosted: Fri Nov 23, 2001 3:40 am     Reply with quote

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
PostPosted: Fri Nov 23, 2001 1:02 pm     Reply with quote

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
PostPosted: Fri Nov 23, 2001 3:24 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group