View previous topic :: View next topic |
Author |
Message |
Kban Guest
|
CRC code needed |
Posted: Tue Jun 22, 2004 2:11 am |
|
|
Hi
I am looking for a CRC code that would run on CC5x compiler. I found some on this forum but since CC5x uses ansi C, and i am not too good at C anyway , it would be very nice if someone can provide me with code that would return CRC16 for a 20byte array, using simple if and for loops so that i can also understand whats happening.
Sorry if this is off topic due to other compiler
Thanks |
|
|
Sigma
Joined: 03 May 2004 Posts: 48 Location: Sg
|
|
Posted: Tue Jun 22, 2004 4:01 am |
|
|
can refer to Ex_crc.c in the examples directory. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jun 22, 2004 6:08 am |
|
|
Using Google you can find hundreds of CRC examples. You are not limited to searching a special version for your compiler since most examples are very short and easy to port.
Many people just choose an example code and copy this into their design and then months later they realise they have a problem: There is not just one CRC-16 method, but there are many!!! When you are communicating with your own applications you don't realize this as all your programs use the same software, but as soon as you want to communicate with someone else you have a problem.
Possible variations have to do with:
- Chosen CRC Polynome
- Initial value
- Reversed data bytes
- Reversed CRC value
- Use of an final XOR and value thereof
Resulting into more than 16 billion possible CRC-algorithms.....
One of the most wide spread CRC-16 algorithms is the CCITT implementation which has a CRC polynome of 0x1021 (x16 + x12 + x5 + 1) and a starting value of 0xFFFF.
Your best choise for compatibility is to search for keywords CCITT and CRC-16. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 22, 2004 12:28 pm |
|
|
If you want to search for CCS source code, do as I suggested
in a recent post. Search Google for exactly this string. It must
have the quotes, and the upper-case OR:
"#use delay" char crc OR crcc
Explanation:
The "#use delay" will find pages related to CCS, and the 'char'
helps to find actual source code. Then put your keywords on
the end, and separate multiple keywords with upper-case OR. |
|
|
|