FastCRC on Teensy 4.0 - Change CRC init value?

Status
Not open for further replies.

quiver

Active member
Hi there,

Hoping to get the attention of the FastCRC library creator, Frank B.

I've got a project I'm trying to transition from Teensy 3.2 to Teensy 4.0. It uses FastCRC to create a 16-bit CRC, but it requires a CRC init that is neither 0x0000 or 0xFFFF. I've been using the generic function as a result, and this has been terrific. I realise hardware CRC support isn't yet enabled for the Teensy 4.0 on the FastCRC library, so I've been trying the kermit or mcrf4xx functions with a modified init value in FastCRCsw.cpp, but this does not yield the same (correct) result that the generic function did on the T3.2. Do the tables only support 0x0000 or 0xFFFF ?

This is what worked on the T3.2:

CRC16.generic(0x1021, 0xabcd, CRC_FLAG_REFLECT, datainput, 14);

Any thoughts?
 
Any thoughts?

Yes :) The Teensy 4 has a different CRC Hardware that can not be used.

The Teensy 3 uses a register to store the seed, the software-variant uses a variable:
Code:
class FastCRC16
{
 ...
private:
#if CRC_SW
[COLOR=#a52a2a]  uint16_t seed;[/COLOR]
...
#endif
...


uint16_t FastCRC16::mcrf4xx(const uint8_t *data,const uint16_t datalen)
{
 // poly=0x1021 init=0xffff refin=true refout=true xorout=0x0000 check=0x6f91
[COLOR=#a52a2a]  seed = 0xffff;[/COLOR]
  return mcrf4xx_upd(data, datalen);
}

So either create a setter for the seed, or add a new CRC variant (Just copy the code from mcrf4xx and modify the seed, or if you don't mind to do it "hackish" just edit the seed value for mcrf4xx)

Have fun,
Frank.
 
Last edited:
Hi Frank,

Thanks for your speedy reply!

You described exactly what I've tried though, and I don't get the correct sum.. You can replicate this by doing the above on a Teensy 3.2 and a Teensy 4.0. If you have an irregular seed, the checksum is different.. and the T3.2 is correct..
 
Status
Not open for further replies.
Back
Top