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

最新文章

  1. 【bzoj2435】[NOI2011]道路修建
  2. HTML5 Web Storage
  3. [SmartFoxServer概述]SFS2X协议
  4. memcpy memmove区别和实现
  5. Yeoman+Express+Angular在Linux上开发配置方法
  6. C# 序列化xml
  7. iOS 10 使用相机及相簿闪退的问题修正
  8. 《University Calculus》-chape4-导数的应用-微分中值定理
  9. CGContextRef CIImageRef详解
  10. 基于OCR的SeeTest框架可行性分析总结
  11. NOIP2001-普及组复赛-第一题-数的计算
  12. 第10章 接口、继承与多态----Object类
  13. sersync实现数据实时同步
  14. [HNOI2003]消防局的设立
  15. JenKins使用pm2部署.net core网站
  16. form表单中使用a标签代替button或commit进行数据提交
  17. java对象是如何创建的
  18. 用js拼接url为pathinfo模式
  19. Linux使用C语言链接MsSQL
  20. [shell基础]——echo命令

热门文章

  1. HDU 1308 What Day Is It?(模拟题)
  2. FPGA学习笔记. DDS
  3. 关于markdown文件插入图片遇到的小问题和解决办法
  4. objective-c 几何类常用方法整理
  5. C++ socket 网络编程 简单聊天室
  6. Codeforces 600E - Lomsat gelral 「$Dsu \ on \ tree$模板」
  7. tomcat启动报错:Injection of autowired dependencies failed
  8. 读写分离MYSQL类
  9. jquery实现模拟select下拉框效果
  10. HTML5+ App开发入门