Howto CRC16

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Howto CRC16

383 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mclane on Fri Oct 05 12:04:54 MST 2012
I have studied the crc code examples for the 1227 but I have no clue how to use them.

I need to calculate a crc16 checksum over a string of chars.
Can anyone help me how to do it?

Where can I find more details about the parameters to be provided to the functions prototyped in crc.h?
0 Kudos
2 Replies

316 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Oct 05 13:17:33 MST 2012

Quote: mclane
I have studied the crc code examples for the 1227 but I have no clue how to use them.

I need to calculate a crc16 checksum over a string of chars.
Can anyone help me how to do it?

Where can I find more details about the parameters to be provided to the functions prototyped in crc.h?



UM10441 Chapter 22: LPC122x CRC engine :confused:
0 Kudos

316 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ArtjomGromak on Fri Oct 05 13:07:07 MST 2012

Quote: mclane

Where can I find more details about the parameters to be provided to the functions prototyped in crc.h?


Sample:

crc.c
uint16_t Crc16( uint8_t *s)
{
unsigned short crc = 0xFFFF;
unsigned char i;

while(*s)
{
crc ^= *s++ << 8;

for( i = 0; i < 8; i++ )
crc = crc & 0x8000 ? ( crc << 1 ) ^ 0x1021 : crc << 1;
}

return crc;
}

crc.h

#ifndef CRC16_H_
#define CRC16_H_

#include <stdint.h>
uint16_t Crc16( uint8_t *s);

#endif
0 Kudos