Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:30:38+00:00 2026-06-12T00:30:38+00:00

I am trying to do crc_table for 12-bit CRC and the algorithm, but always

  • 0

I am trying to do crc_table for 12-bit CRC and the algorithm, but always I got wrong results.

Can you help me? To create crc table I try:

void crcInit(void)
{
    unsigned short  remainder;
    int    dividend;
    unsigned char  bit;

    for (dividend = 0; dividend < 256; ++dividend)
    {
        remainder = dividend << 4;

        for (bit = 8; bit > 0; --bit)
        {
            if (remainder & 0x800)
            {
                remainder = (remainder << 1) ^ 0x180D; //Polynomio of CRC-12
            }
            else
            {
                remainder = (remainder << 1);
            }
        }
       crcTable[dividend] = remainder;
    }

}

I updated that and CRC algorithm is:

unsigned short crcFast(unsigned char const message[], int nBytes)
{
    unsigned short remainder = 0x0000;
    unsigned char  data;
    int  byte;


    /*
     * Divide the message by the polynomial, a byte at a time.
     */
    for (byte = 0; byte < nBytes; ++byte)
    {
        data = message[byte] ^ (remainder >> 4);
    remainder = crcTable[data] ^ (remainder << 8);
    }

    /*
     * The final remainder is the CRC.
     */
    return (remainder ^ 0);

}

But It isn’t working…..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:30:40+00:00Added an answer on June 12, 2026 at 12:30 am

    This doesn’t seem right:

    if (remainder & 10000000)
    

    It looks like you are intending this number to be binary, but it is actually decimal. You should use a hex literal instead (0x80).

    There also seem to be problems with this number, and with the size of the shift you do: This test should check if the high-order bit of the remainder is set. Since you are doing a 12-bit CRC, the mask should be 0x800 (binary 100000000000). And the shift above that should probably be:

    remainder = dividend << 4;
    

    to set the leftmost 8 bits of the remainder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a function that deletes an entire list, but I
trying to get my first HTML/CSS uni assignment sorted but have become a bit
I am currently trying to implement an algorithm to select a unique (16-bit) identifier.
Trying to create an Oracle trigger that runs after a table is updated in
Trying to figure out how I can do this properly. The print_r looks like
Trying a simple project to create my own (very basic) data binding. I have
Trying to create a clickable event so that when #next is clicked the html
Trying to create a data.frame like this: a = foo bar = data.frame(a =
I am currently trying to implement a CRC-32 for an incoming datastream (Serial communication)
Basically I'm trying to start some unit tests in google test but not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.