This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C51 - Calculating the parity

Has someone a good hint how to implement a parity-calculation of a byte in the most efficient way on an C51-device?

Parents
  • Here's a simple one:

    static char const code nibble_parity[16] =
                       { 0, 1, 1, 0,
                         1, 0, 0, 1,
                         1, 0, 0, 1,
                         0, 1, 1, 0 };
    char calc_even_parity(uchar byte)
    {
        return( nibble_parity[byte&0xf] ^ nibble_parity[(byte>>4)&0xf]);
    }
    
    char calc_odd_parity(uchar byte)
    {
        return(!calc_even_parity(byte));
    }
    


    I've been using it for years

Reply
  • Here's a simple one:

    static char const code nibble_parity[16] =
                       { 0, 1, 1, 0,
                         1, 0, 0, 1,
                         1, 0, 0, 1,
                         0, 1, 1, 0 };
    char calc_even_parity(uchar byte)
    {
        return( nibble_parity[byte&0xf] ^ nibble_parity[(byte>>4)&0xf]);
    }
    
    char calc_odd_parity(uchar byte)
    {
        return(!calc_even_parity(byte));
    }
    


    I've been using it for years

Children
No data