I get a little nervous when you say "I need to check that all the bits add up to an odd number". It is my experience that parity bits are used in each byte during transmit (or storage), not as a check on the entire message. You have a good idea about shifting and counting the LSB (Least Significant Bit) each time. There is a simple way to do that because the LSB of the count of bits will show if it is odd or even parity. Start by clearing the result variable. then for eight times, add the byte under test to the result and shift the byte under test to right by 1. There is no need to do the eight shift as you have finished counting the eight bits by then. Then just look at the LSB in the result variable, if it is a 1 then byte has odd parity. You don't need to be concerned with what the rest of the result variable contains. Bill ----- Original Message ----- From: "Brian Millward" To: Sent: Friday, June 09, 2006 5:20 PM Subject: [PIC] calculating parity bits >I am fairly new to PIC programming and I am building a radio clock to >decode > Rugby MSF transmissions. > > > > It all works, but I have not done any parity checking. > > > > I have some BCD variables and a checksum bit and I need to check that all > the bits add up to an odd number. > > > > I have thought of checking the lsb, then shifting right and repeating etc, > adding all the bits together, but I am sure that there is an easier way I > just cannot think of it > > > > Apologies for seeming to be a bit dense, but I am trying to master it. > > > > By the way, I am using CCS 'C' compiler. > > > > Thanks for any help you may be able to give. > > > > Regards ... Brian > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist