STM32F7 12 Cyclic redundancy check calculation unit (CRC)

Started by tha, November 09, 2022, 07:36:36 AM

Previous topic - Next topic

tha

12 Cyclic redundancy check calculation unit (CRC)

12.1 Introduction

The CRC (cyclic redundancy check) calculation unit ถูกใช้เพื่อให้รับ a CRC code จาก 8-, 16-or 32-bit data word และตัวสร้างสมการโพลิโนเมี่ยล.

ในบรรดา applications อื่น, CRC-based techniques ถูกใช้เพื่อตรวจสอบ data transmission หรือความสมบูรณ์ของการจัดเก็บ. ในในขอบเขตของ the functional safety standards, พวกเขาเสนอวิธีการการตรวจสอบ the Flash memory integrity. The CRC calculation unit ช่วยคำนวณ a signature ของ the software ในระหว่าง runtime, เพื่อถูกเปรียบเทียบกับ a reference signature ที่สร้างขึ้นที่ linktime และเก็บไว้ที่ a given memory location.

tha

12.2 CRC main features

•   ใช้ CRC-32 (Ethernet) polynomial: 0x4C11DB7

•   อีกวิธีหนึ่ง, ใช้พหุนามที่สามารถโปรแกรมได้อย่างเต็มที่ด้วยขนาดที่สามารถโปรแกรมได้ (7, 8, 16, 32 bits)
•   จัดการ 8-,16-, 32-bit data size
•   สามารถโปรแกรมได้ CRC initial value
•   Single input/output 32-bit data register
•   Input buffer เพื่อหลีกเลี่ยง bus stall ในระหว่างการคำนวณ
•   CRC computation ที่ทำใน 4 AHB clock cycles (HCLK) สำหรับ the 32-bit data size
•   General-purpose 8-bit register (สามารถถูกใช้สำหรับการเก็บชั่วคราว)
•   ทางเลือกการย้อนกลับของ I/O data

tha

12.3 CRC functional description

12.3.1 CRC block diagram



12.3.2 CRC internal signals



tha

12.3.3 CRC operation

The CRC calculation unit มี a single 32-bit read/write data register (CRC_DR). มันถูกใช้เพื่อป้อน new data (write access), และเก็บผลลัพธ์ของ the previous CRC calculation (read access).

แต่ละ write operation ไปยัง the data register จะสร้างการรวมกันของ the previous CRC value (ที่เก็บใน CRC_DR) และค่าใหม่อีกค่า. CRC computation ถูกทำบน the whole 32-bit data word หรือ byte by byte ขึ้นอยู่กับ the format ของ the data ที่กำลังถูกเขียน.

The CRC_DR register สามารถถูกเข้าถึงโดย word, วางแนวชิดขวา half-word และวางแนวชิดขวา byte. สำหรับ the other registers เฉพาะ 32-bit access ถูกอนุญาต.

ระยะเวลาของการคำนวณขึ้นอยู่กับความกว้างของข้อมูล:
•   4 AHB clock cycles for 32-bit
•   2 AHB clock cycles for 16-bit
•   1 AHB clock cycles for 8-bit

tha

An input buffer ช่วยให้เขียน a second data ได้ทันทีโดยไม่มีการรอสำหรับ wait states ใดๆเนื่องจาก the previous CRC calculation.

The data size สามารถถูกปรับได้แบบไดนามิคเพื่อทำให้ต่ำสุด the number of write accesses สำหรับ a given number of bytes. ตัวอย่างเช่น, a CRC สำหรับ 5 bytes สามารถถูกคำนวณด้วย a word write ตามด้วย a byte write.

The input data สามารถถูกกลับเป็นตรงกันข้าม, เพื่อจัดการ the various endianness schemes. The reversing operation สามารถถูกดำเนินการบน 8 bits, 16 bits and 32 bits ขึ้นอยู่กับ the REV_IN[1:0] bits ใน the CRC_CR register.

ตัวอย่างเช่น: input data 0x1A2B3C4D ถูกใช้สำหรับ CRC calculation ดังนี้:
•   0x58D43CB2 ด้วย bit-reversal ที่ทำโดย byte
•   0xD458B23C with bit-reversal done by half-word
•   0xB23CD458 with bit-reversal done on the full word

tha

The output data สามารถถูกกลับเป็นตรงกันข้ามได้อีกด้วยโดยการเซ็ต the REV_OUT bit ใน the CRC_CR register.

The operation ถูกทำที่ bit level: ตัวอย่างเช่น, output data 0x11223344 จะถูกแปลงเป็น 0x22CC4488.

The CRC calculator สามารถถูกเริ่มต้นเป็นค่าที่สามารถโปรแกรมได้โดยใช้ the RESET control bit ใน the CRC_CR register (ค่าโดยเริ่มต้นคือ 0xFFFFFFFF).

The initial CRC value สามารถถูกโปรแกรมด้วย the CRC_INIT register. The CRC_DR register จะถูกเริ่มต้นโดยอัตโนมัติเมื่อ CRC_INIT register write access.

The CRC_IDR register สามารถถูกใช้เพื่อเก็บ a temporary value ที่เกี่ยวข้องกับ CRC calculation. มันไม่ได้รับผลกระทบโดย the RESET bit ใน the CRC_CR register.

tha

Polynomial programmability

The polynomial coefficients สามารถโปรแกรมได้ผ่านทาง the CRC_POL register, และ the polynomial size สามารถถูกกำหนดค่าเป็น 7, 8, 16 or 32 bits โดยการโปรแกรม the POLYSIZE[1:0] bits ใน the CRC_CR register. แม้ว่า polynomials จะไม่ถูกรองรับ.

ถ้า the CRC data น้อยกว่า 32-bit, ค่าของมันสามารถถูกอ่านจาก the least significant bits of the CRC_DR register.

เพื่อให้ได้ a reliable CRC calculation, การเปลี่ยนแปลงทันทีของค่าพหุนามหรือขนาดสามารถไม่ดำเนินการได้ในระหว่าง a CRC calculation. ผลที่ตามมา, ถ้า a CRC calculation กำลังดำเนินการอยู่, the application ต้องอย่างใดอย่างหนึ่ง reset มันหรือดำเนินการ a CRC_DR read ก่อนการเปลี่ยน the polynomial.

The default polynomial value คือ the CRC-32 (Ethernet) polynomial: 0x4C11DB7.

tha

12.4 CRC registers

12.4.1 Data register (CRC_DR)

Address offset: 0x00
Reset value: 0xFFFF FFFF



Bits 31:0 DR[31:0]: Data register bits
     register นี้ถูกใช้เพื่อเขียน new data ไปยัง the CRC calculator.
     มันเก็บ the previous CRC calculation result เมื่อมันถูกอ่าน.
     ถ้า the data size น้อยกว่า 32 bits, the least significant bits จะถูกใช้เพื่อ เขียน/อ่าน the correct value.