STM32 CRC-32 Calculator Unit

AN4187 - Using the CRC peripheral in the STM32 family

At start up, the algorithm sets CRC to the Initial_Crc XOR with the Input_Data.

Once CRC MSB is equal to one, the algorithm shifts CRC one bit to the left and XORs it with the POLY.

Otherwise, it only shifts CRC one bit to the left.

Figure 3 shows the step-by-step algorithm execution for the following conditions:

– Input_Data = 0xC1

– POLY = 0xCB

– Initial_Crc = 0xFF

All STM32 devices implement a CRC peripheral as described in Section 1.1.

The CRC calculation unit has a single 32-bit read/write data register (CRC_DR).

It is used to input new data (write access) and hold the result of the previous CRC calculation (read access).

Each write operation to the data register creates a combination of the previous CRC value (stored in CRC_DR) and the new one.

Figure 4. CRC calculation unit block diagram

To compute a CRC of any supported data, you must follow these steps:

1. Enable the CRC peripheral clock via the RCC peripheral.

2. Set the CRC Data Register to the initial CRC value by configuring the Initial CRC value register (CRC_INIT).(a)

3. Set the I/O reverse bit order through the REV_IN[1:0] and REV_OUT bits respectively in CRC Control register (CRC_CR).(a)

4. Set the polynomial size and coefficients through the POLYSIZE[1:0] bits in CRC Control register (CRC_CR)
and CRC Polynomial register (CRC_POL) respectively.(b)

5. Reset the CRC peripheral through the Reset bit in CRC Control register (CRC_CR).

6. Set the data to the CRC Data register.

7. Read the content of the CRC Data register.

8. Disable the CRC peripheral clock.

In firmware package, the CRC_usage example runs the CRC checksum code computing an array data (DataBuffer) of 256 supported data type.

For a full description, please refer to the file Readme.txt in the CRC_usage folder.

a. Applicable only for STM32F0xx and STM32F3xx devices

b. Applicable only for STM32F3xx devices

时间: 2024-10-09 14:17:38

STM32 CRC-32 Calculator Unit的相关文章

CRC32 of Ether FCS with STM32

Everyone knows that STM32F1xx, STM32F2xx, STM32F4xx have a hardware unit with a polynomial CRC32 0x04C11DB7. And he, in general, work. But only a checksum for some reason does not coincide with that calculated softvarno. The Google usually 2 types of

如何在IAR中配置CRC参数(转)

源:如何在IAR中配置CRC参数 前言 STM32全系列产品都具有CRC外设,对CRC的计算提供硬件支持,为应用程序节省了代码空间.CRC校验值可以用于数据传输中的数据正确性的验证,也可用于数据存储时的完整性检查.在IEC60335中,也接受通过CRC校验对FLASH的完整性进行检查.在对FLASH完整性检查的应用中,需要事先计算出整个FLASH的CRC校验值(不包括最后保存CRC值的字节),放在FLASH的末尾.在程序启动或者运行的过程中重新用同样的方法计算整个FLASH的CRC校验值,然后与

STM32的CRC32 软件实现代码

对于STM32的32位CRC,如果假定它的一个主要目的是为了校验往内部FLASH存储数据的可靠性,那么(余数)初值是全1当然是比较合理的.由于STM32的32位CRC是纯32位,即每次必须输入32位的数,所以如果数据不到32位,应该往低位用1来填充比较合理: 另外,如果输入数据是 "1234"-0x31 0x32 0x33 0x34, 那么输入的CRC数据是 0011-0100 0011-0011 0011-0010 0011-0001 :: 0x34333231 由于STM32的32

STM32的CRC32 测试代码

// STM32 CRC32 Test App - [email protected] #include <windows.h> #include <stdio.h> DWORD Crc32( DWORD Crc, DWORD Data ) { int i; Crc = Crc ^ Data; for ( i = 0; i < 32; i++ ) if ( Crc & 0x80000000 ) Crc = ( Crc << 1 ) ^ 0x04C11DB7

CRC校验码的verilog实现与仿真结果

循环冗余校验码(CRC)的基本原理是: 将被处理的报文比特序列当做一个二进制多项式A(x)的系数,(任意一个由二进制位串组成的代码都可以和一个系数仅为'0'和'1'取值的多项式一一对应.例如:代码1010111对应的多项式为x6+x4+x2+x+1,而多项式为x5+x3+x2+x+1对应的代码101111),该系数乘以2^n(n为生成多项式g(x)中x的最高次幂)以后再除以发送方和接收方事先约定好的生成多项式g(x)后,求得的余数P(x)就是CRC校验码,把它副到原始的报文A(x)后面形成新的报

Keil调试STM32中解析main开始前的工作

Cortex M3的内核有三种启动方式,其分别是: A.通过boot引脚设置可以将中断向量表定位于SRAM区,即起始地址为0x2000000,同时复位后PC指针位于0x2000000处: B.通过boot引脚设置可以将中断向量表定位于FLASH区,即起始地址为0x8000000,同时复位后PC指针位于0x8000000处: C.通过boot引脚设置可以将中断向量表定位于内置Bootloader区, Cortex-M3内核规定,起始地址必须存放堆顶指针,而第二个地址则必须存放复位中断入口向量地址,

CRC循环冗余校验码总结(转)

转自 http://blog.csdn.net/u012993936/article/details/45337069 一.CRC简介 先在此说明下什么是CRC:循环冗余码校验 英文名称为Cyclical Redundancy Check,简称CRC,它是利用除法及余数的原理来作错误侦测(Error Detecting)的.实际应用时,发送装置计算出CRC值并随数据一同发送给接收装置,接收装置对收到的数据重新计算CRC并与收到的CRC相比较, 若两个CRC值不同,则说明数据通讯出现错误 那么其实

CRC循环冗余校验码总结

一.CRC简介 先在此说明下什么是CRC:循环冗余码校验 英文名称为Cyclical Redundancy Check,简称CRC,它是利用除法及余数的原理来作错误侦测(Error Detecting)的.实际应用时,发送装置计算出CRC值并随数据一同发送给接收装置,接收装置对收到的数据重新计算CRC并与收到的CRC相比较,若两个CRC值不同,则说明数据通讯出现错误 那么其实CRC有比较多种,比如CRC16.CRC32 ,为什么叫16.32呢.在这里并非与位有和关系.而是由所确定的多项式最高次幂

CRC 自动判断大端 小端

/* aos_crc64.c -- compute CRC-64 * Copyright (C) 2013 Mark Adler * Version 1.4 16 Dec 2013 Mark Adler */ /* This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising