calculates CRC16 as per EN13757-4

[复制链接]
877|11
手机看帖
扫描二维码
随时随地手机跟帖
yutianhai|  楼主 | 2017-12-4 08:22 | 显示全部楼层 |阅读模式
做个笔记:
#include "crc.h"
#include <stdint.h>
//------------------------------------------------------------------------------------------------
-------
// uint16 crcCalc(uint16 crcReg, uint8 crcData)
//
// DESCRIPTION:
// Calculates the 16-bit CRC. The function requires that the CRC_POLYNOM
// is defined, which gives the wanted CRC polynom.
//
// ARGUMENTS:
// uint8 crcData - Data to perform the CRC-16 operation on.
// uint16 crcReg - Current or initial value of the CRC calculation
//
// RETURN:
// The value returned is the 16-bit CRC (of the data supplied so far).
//------------------------------------------------------------------------------------------------
-------
uint16_t crcCalc(uint16_t crcReg, uint8_t crcData)
{
uint8_t i;
for (i = 0; i < 8; i++)
{
// If upper most bit is 1
if (((crcReg & 0x8000) >> 8) ^ (crcData & 0x80))
crcReg = (crcReg << 1) ^ CRC_POLYNOM;
else
crcReg = (crcReg << 1);
crcData <<= 1;
}
return crcReg;
}
// CRC_POLYNOM 0x3D65

相关帖子

dirtwillfly| | 2017-12-4 16:17 | 显示全部楼层

使用特权

评论回复
wwppd| | 2017-12-5 21:41 | 显示全部楼层
这个校验位是多少?

使用特权

评论回复
jkl21| | 2017-12-5 21:41 | 显示全部楼层
以前在FPGA上做过CRC校验,麻烦多了。

使用特权

评论回复
maqianqu| | 2017-12-5 21:42 | 显示全部楼层
EN13757-4是什么?

使用特权

评论回复
dspmana| | 2017-12-5 21:42 | 显示全部楼层
请问,msp430执行这个代码需要多个周期?

使用特权

评论回复
wwppd| | 2017-12-5 21:43 | 显示全部楼层
校验的速度应该快不了。

使用特权

评论回复
jkl21| | 2017-12-5 21:43 | 显示全部楼层
看到楼主做的应该是8位的CRC吧

使用特权

评论回复
maqianqu| | 2017-12-5 21:43 | 显示全部楼层
CRC16源代码网上有很多。

使用特权

评论回复
dspmana| | 2017-12-5 21:43 | 显示全部楼层
有很多的数据的是怎么实现的CRC算法的?

使用特权

评论回复
hotpower| | 2017-12-24 20:33 | 显示全部楼层
本帖最后由 hotpower 于 2017-12-24 20:42 编辑

http://www.21ic.com/tools/HotPower/HotWC3_V1.23.html

使用特权

评论回复
hotpower| | 2017-12-24 20:34 | 显示全部楼层
它可以自动生成CRC表格和CRC源码。可以生成5种算法

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

18

帖子

1

粉丝