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

 

转载于:https://www.cnblogs.com/shangdawei/p/4606428.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值