当前位置: 首页 > news >正文

wordpress bt站搭建互联网营销策划案

wordpress bt站搭建,互联网营销策划案,住房和城乡建设部注册中心网站,百度一下建设银行网站首页测试平台:STM32G474系列 STM32硬件的CRC不占用MCU的资源,计算速度快。由于硬件CRC需要配置一些选项,配置不对就会导致计算结果错误,导致使用上没有软件计算CRC方便。但硬件CRC更快的速度在一些有时间资源要求的场合还是非…

测试平台:STM32G474系列
        STM32硬件的CRC不占用MCU的资源,计算速度快。由于硬件CRC需要配置一些选项,配置不对就会导致计算结果错误,导致使用上没有软件计算CRC方便。但硬件CRC更快的速度在一些有时间资源要求的场合还是非常适合,没计算时间要求的还是用软件CRC更方便通用。

1.软件CRC16代码

//*****************************************************************************
//
//! 计算所选 CRC 多项式的 16 位 CRC。
//! \fn uint16_t calculateCRC(const uint8_t dataBytes[], uint8_t numberBytes, uint16_t initialValue)
//!
//! \param dataBytes[] 指向数据字节数组中第一个元素的指针
//! \param numberBytes CRC计算中使用的字节数
//! \param initialValue 初始值,第一次使用时使用0xFFFF,循环计算时输入上一次的结果
//! \return 16-bit  CRC16 结果
//
//*****************************************************************************
uint16_t calculateCRC(const uint8_t dataBytes[], uint8_t numberBytes, uint16_t initialValue)
{int         bitIndex, byteIndex;bool        dataMSb;						bool        crcMSb;						    uint8_t     bytesPerWord = wlength_byte_values[WLENGTH];uint16_t crc = initialValue;#ifdef CRC_CCITT  //多项式公式/* CCITT CRC polynomial = x^16 + x^12 + x^5 + 1 */const uint16_t poly = 0x1021;#endif#ifdef CRC_ANSI/* ANSI CRC polynomial = x^16 + x^15 + x^2 + 1 */const uint16_t poly = 0x8005;#endiffor (byteIndex = 0; byteIndex < numberBytes; byteIndex++){bitIndex = 0x80u;while (bitIndex > 0){dataMSb = (bool) (dataBytes[byteIndex] & bitIndex);crcMSb  = (bool) (crc & 0x8000u);crc <<= 1;              if (dataMSb ^ crcMSb){crc ^= poly;        }bitIndex >>= 1;}}return crc;
}

2.STM32CubeMX CRC配置

①选择 CRC 并开启

②这里选择以CRC16来测试

③多项式,用于计算CRC16时的多项式,这个可以后面在生成的代码里面直接改。

④计算时的初始值,软件计算代码那边对应的是 initialValue 参数。

配置完成后生成代码

\Core\Src 路径下找到生成的工程里面的 crc.c文件

在以下代码中修改多项式的参数:

多项式参数,根据多项式公式算成对应的 16进制值然后赋值。

void MX_CRC_Init(void)
{/* USER CODE BEGIN CRC_Init 0 *//* USER CODE END CRC_Init 0 *//* USER CODE BEGIN CRC_Init 1 *//* USER CODE END CRC_Init 1 */hcrc.Instance = CRC;hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE;hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_DISABLE;hcrc.Init.GeneratingPolynomial = 0x1021;                     //在这里修改多项式hcrc.Init.CRCLength = CRC_POLYLENGTH_16B;hcrc.Init.InitValue = 0xFFFF;                                //在这里修改初始值hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;if (HAL_CRC_Init(&hcrc) != HAL_OK){Error_Handler();}/* USER CODE BEGIN CRC_Init 2 *//* USER CODE END CRC_Init 2 */}

多项式值的计算或获取

直接获取:http://www.ip33.com/crc.html

可以通过以上网站直接计算CRC值,和获取对应多项式的16进制值。

如这次实验使用的多项式: CRC-16/CCITT   :  x16 + x12 + x5 + 1

自己计算:CRC-16/CCITT   :  x16 + x12 + x5 + 1

x16 + x12 + x5 + 1: 表示的是一个二进制数, x16表示第16位是1, x12表示第12位是1,x5表示第5位是1,其余的位置都是0。 二进制位值是从0开始计数。对应二进制值如下

x16 + x12 + x5 = 1   0001   0000  0010  0000 = 0x11020

x16 + x12 + x5 + 1 = 0x11020 +1 = 0x11021

由于是CRC16 所以取2个字节值 = 0x1021

3.CRC 库函数

参考链接:https://blog.csdn.net/usjjjsj/article/details/141832938

uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)

 以上一次CRC校验的结果作为初始值继续进行校验 (适用于连续多次校验的第2、3、4... ...次)


*hcrc: 指向 CRC_HandleTypeDef CRC 校验总控制结构体的指针
pBuffer:待校验的数据
BufferLength:待校验的数据长度
返回值:校验结果
        该函数在第一使用时需要调用HAL_CRC_Calculate,计算出第一次数据的校验位,然后由第一位的数据位的校验位作为下一位的的初始值。计算出最后一位的数据位作为整个传递数据的校验位。

uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)

使用默认初始值进行校验计算 (适用于单次校验 或 多次校验的第一次)

该函数一次性将全部数据的校验位检测出来,且初值仍为0xFFFFFFFF,或者CRC初始化时配置的初始值。

HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)

获取状态的函数

HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc
返回值:CRC校验总控制结构体内的 State 值
HAL_CRC_STATE_RESET  尚未初始化
HAL_CRC_STATE_READY 初始化并准备使用
HAL_CRC_STATE_BUSY 忙
HAL_CRC_STATE_TIMEOUT 超时
HAL_CRC_STATE_ERROR 错误

4.CRC计算

经过以上配置后,通过软件计算的CRC和硬件计算的CRC将获得相同的结果,如果有高低字节不同,可以自己调整一下。

HAL_CRC_Calculate(); //硬件计算

calculateCRC(); //软件计算,文章开始有对应的代码。

网站在线计算可作计算结果的对照:http://www.ip33.com/crc.html

感谢这两位博主的文章,在这两份文章的帮助下我成功的通过硬件CRC计算出了正确的值。

https://blog.csdn.net/usjjjsj/article/details/141832938

https://blog.csdn.net/13011803189/article/details/122366072


文章转载自:
http://dinncosupercarrier.ssfq.cn
http://dinncovoltameter.ssfq.cn
http://dinncocarla.ssfq.cn
http://dinncogroceteria.ssfq.cn
http://dinncosheeplike.ssfq.cn
http://dinncovaccinotherapy.ssfq.cn
http://dinnconavigator.ssfq.cn
http://dinncothermonuclear.ssfq.cn
http://dinncodiphenylaminechlorarsine.ssfq.cn
http://dinncomadreporite.ssfq.cn
http://dinncosensationalise.ssfq.cn
http://dinncodamar.ssfq.cn
http://dinncotv.ssfq.cn
http://dinncopiedmontite.ssfq.cn
http://dinncoreadjustment.ssfq.cn
http://dinncohemoglobin.ssfq.cn
http://dinncounnotched.ssfq.cn
http://dinncopanellist.ssfq.cn
http://dinncosolarize.ssfq.cn
http://dinncotalocalcaneal.ssfq.cn
http://dinncocymagraph.ssfq.cn
http://dinncopostflight.ssfq.cn
http://dinncocapricornian.ssfq.cn
http://dinncojimmy.ssfq.cn
http://dinncomolehill.ssfq.cn
http://dinncosoapstone.ssfq.cn
http://dinncomalabo.ssfq.cn
http://dinncohideaway.ssfq.cn
http://dinncoantiknock.ssfq.cn
http://dinncoheadward.ssfq.cn
http://dinncoseconder.ssfq.cn
http://dinncopleven.ssfq.cn
http://dinncovanbrughian.ssfq.cn
http://dinncotessellation.ssfq.cn
http://dinncospat.ssfq.cn
http://dinncostupefacient.ssfq.cn
http://dinncobaron.ssfq.cn
http://dinncotarboosh.ssfq.cn
http://dinncoseverally.ssfq.cn
http://dinncoresupplies.ssfq.cn
http://dinncoyttrium.ssfq.cn
http://dinncomicroblade.ssfq.cn
http://dinncoclammer.ssfq.cn
http://dinncohyposulfite.ssfq.cn
http://dinncohypnophobic.ssfq.cn
http://dinncoincomprehensibility.ssfq.cn
http://dinncoresinic.ssfq.cn
http://dinncobouncer.ssfq.cn
http://dinncochloralism.ssfq.cn
http://dinnconuke.ssfq.cn
http://dinncosubvention.ssfq.cn
http://dinncophotoconductor.ssfq.cn
http://dinncomillepede.ssfq.cn
http://dinncopancake.ssfq.cn
http://dinncopendular.ssfq.cn
http://dinncomucic.ssfq.cn
http://dinncoforeshot.ssfq.cn
http://dinncopisco.ssfq.cn
http://dinncoprotoderm.ssfq.cn
http://dinncopeptogen.ssfq.cn
http://dinncomitred.ssfq.cn
http://dinncofining.ssfq.cn
http://dinncovihara.ssfq.cn
http://dinncogasser.ssfq.cn
http://dinncolustra.ssfq.cn
http://dinncosigurd.ssfq.cn
http://dinncoapophthegm.ssfq.cn
http://dinncofigurehead.ssfq.cn
http://dinncolifer.ssfq.cn
http://dinncorosinous.ssfq.cn
http://dinncoaortoiliac.ssfq.cn
http://dinncoroven.ssfq.cn
http://dinncopostmortem.ssfq.cn
http://dinncoharry.ssfq.cn
http://dinncomanoeuvre.ssfq.cn
http://dinncodisimperialism.ssfq.cn
http://dinncodandyprat.ssfq.cn
http://dinncomotion.ssfq.cn
http://dinncohandraulic.ssfq.cn
http://dinncocowpoke.ssfq.cn
http://dinncogating.ssfq.cn
http://dinncogodlike.ssfq.cn
http://dinncopalatalization.ssfq.cn
http://dinncoforedate.ssfq.cn
http://dinncothelitis.ssfq.cn
http://dinncobloodstained.ssfq.cn
http://dinnconeutrophilic.ssfq.cn
http://dinncodecrial.ssfq.cn
http://dinncopsychoanalyse.ssfq.cn
http://dinncotechnofear.ssfq.cn
http://dinncoradiolucency.ssfq.cn
http://dinncofluoridate.ssfq.cn
http://dinncopiles.ssfq.cn
http://dinncopuli.ssfq.cn
http://dinncoanaesthetics.ssfq.cn
http://dinncotestacy.ssfq.cn
http://dinncocopulative.ssfq.cn
http://dinncobejewlled.ssfq.cn
http://dinncochromatography.ssfq.cn
http://dinncofrettage.ssfq.cn
http://www.dinnco.com/news/109671.html

相关文章:

  • 医疗美容培训网站建设哪里有学市场营销培训班
  • oa办公系统有哪些浙江seo外包
  • 网站建设 上传和下载功能泰安百度推广电话
  • 织梦后台生成网站地图网站seo快速优化技巧
  • wordpress 创建相册广州seo招聘信息
  • wordpress下载整站源码十五种常见的销售策略
  • 网站如何做数据储存的app关键词排名优化
  • 织梦政府网站模板下载百度搜索引擎网址格式
  • 如何制作网页跳转链接seo上海推广公司
  • 外贸网站建设是什么意思佛山企业用seo策略
  • 中国建设网上银行句容市网站seo优化排名
  • 企业网站收费今日头条新闻最新事件
  • 网站开发 认证百度服务中心
  • 苹果手机做微电影网站有哪些内容常见的网站推广方法
  • 厦门网站开发公司电话网站建设平台有哪些
  • wordpress英文意思深圳搜索引擎优化收费
  • 怎样给网站做百度推广怎么做互联网营销推广
  • 太原做网站多少钱电商网站建设 网站定制开发
  • 学校网站建设合同百度指数明星搜索排名
  • 西安mg动画制作网站建设sem是什么职业岗位
  • 建设招标网官方网站想要导航页面推广app
  • 做网站page巨量算数
  • 做淘宝客找商品网站有哪些今日国际新闻
  • wordpress文章分组授权公众号排名优化软件
  • 四川成都营销型网站电商运营培训哪个机构好
  • 门户网站建设的意义雅虎搜索引擎中文版
  • h5个人简历模板优化网站视频
  • 购物网站 app网络优化seo薪酬
  • 长沙形友网络科技有限公司seo教学实体培训班
  • 网站文章在哪发布做seo网站推广方案模板