2025-02-06 5:31 AM
Hello,
I’m encountering an issue where I’m unable to fully understand the behavior of the GUI in relation to the commands being transmitted via serial USB to the NUCLEO. I’ve figured out that there is a CRC at the end of the raw data being transmitted through USB. However, despite trying several online calculators to generate the same CRC, I haven’t been able to match the CRC present in the raw data. Is there a specific algorithm used to calculate the CRC? I am attaching two pictures that show the result of calculating the CRC and the CRC generated by the DEMO GUI. Perhaps I’m misunderstanding how the GUI operates, but I assumed the GUI was responsible for generating the CRC in this case.
Thanks in advance for your help.
Best regards,
Dominik Limber
Solved! Go to Solution.
2025-02-13 1:28 PM
I was trying to verify the CRC from the documentation using a calculator, but I couldn't get the same result. However, I found a simple algorithm that works:
Example:
Input (HEX): A4 04 00
Expected CRC: 58
CALCULATION
A4 (HEX) = 164(DEC)
04 (HEX) = 4 (DEC)
00 (HEX) = 0(DEC)
Sum: 0 + 4 + 164 = 168
Modulo operation: 256%168 = 88
88 in HEX = 0x58
Result: CRC = 0x58
It works fine. From what I can tell, the polynomial mentioned in the documentation might not be used for CRC in the communication between the PC and the NUCLEO. Instead, the CRC seems to be calculated using this simple equation—or maybe I just got lucky and overthought it.
2025-02-13 12:01 PM
Okey i found out solution.
2025-02-13 12:34 PM
For the non-dyslexic the L9961
https://www.st.com/resource/en/datasheet/l9961.pdf#page=40
Polynomial 8-bit as 0x107 or 0x07, initialized with zero
Patterns (hex)
A4 04 00 58
55 09 00 40 05 11 21 01 2A
A4 95 2A 99 2D
2025-02-13 1:28 PM
I was trying to verify the CRC from the documentation using a calculator, but I couldn't get the same result. However, I found a simple algorithm that works:
Example:
Input (HEX): A4 04 00
Expected CRC: 58
CALCULATION
A4 (HEX) = 164(DEC)
04 (HEX) = 4 (DEC)
00 (HEX) = 0(DEC)
Sum: 0 + 4 + 164 = 168
Modulo operation: 256%168 = 88
88 in HEX = 0x58
Result: CRC = 0x58
It works fine. From what I can tell, the polynomial mentioned in the documentation might not be used for CRC in the communication between the PC and the NUCLEO. Instead, the CRC seems to be calculated using this simple equation—or maybe I just got lucky and overthought it.