Howto CRC16

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Howto CRC16

1,267 次查看
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 项奖励
回复
2 回复数

1,200 次查看
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 项奖励
回复

1,200 次查看
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 项奖励
回复