Skip to main content
Kevlar700
Associate II
September 28, 2022
Question

Is CRC-7 X7+X3+X0 supported by STM32L4R9

  • September 28, 2022
  • 2 replies
  • 1497 views

I shall just write a function in software but I would be interested to know if it is supported or not by the CRC peripheral hardware.

STM32 cube MX configurator does not allow you to choose X7 for the 7bit (8 term) polynomial described on page 21 of this datasheet?

It is also prevented by a length check on line 111 of stm32l4xx_hal_crc_ex.c

(case CRC_POLYLENGTH_7B)

"https://www.sciosense.com/wp-content/uploads/documents/SC-000897-DS-7-ENS210-Datasheet.pdf"

Thank You

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
September 28, 2022

Should support 7, 8, 16, 32-bits with proper incantations.

Demonstrably capable of 5 and 24-bit CRC with ingenuity. Depends a lot on how the data presents, and methods likely applicable for 3 thru 31-bit.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
September 28, 2022

The 17-bit data pattern probably not helpful in this context

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
September 29, 2022

Mechanics for 32-bit implementation, ingesting 17-bit as singular word

uint32_t crc7_test32(uint32_t data) // ENS210 - EMU32HW - sourcer32@gmail.com
{
 int i = 32;// width of crc
 uint32_t init = 0x00000000; // yes, zero
 uint32_t poly = (0x89 << (32 - 7)); // left align 32-bit
 uint32_t crc;
 
 data = (data & 0x1FFFF); // mask data word, or only 17-bits, right aligned
 
 crc = data ^ init; // apply
 
 while(i--)
 {
 if (crc & 0x80000000) // high order 32-bit
 crc = (crc << 1) ^ poly;
 else
 crc <<= 1; // left shifting
 }
 
 crc = ((crc >> (32 - 7)) ^ 0x7F); // align, masked by left constraints, invert
 
 return(crc);
} // sourcer32@gmail.com

Could probably make the 7-bit HW work too, Initialize at ZERO, and INVERT output

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..