Frequently Asked Question

CAN: How can I add a CRC to a CAN message?
Last Updated 3 months ago

If you wish to let your CAN messages contain a CRC of the message you can do that by editing certain settings in the CAN Configuration within TPT. The first step is to make a signal into a CRC-Signal. After this is done, there are two ways to specify the CRC that is added to the message each time TPT sends the message through the CAN bus. 


1. You can write a dll to specify how the CRC is calculated. Set this dll as the Custom CRC dll and set the CRC definition to „Calculate crc with custom dll“. An example how to create this dll is attached, please modify the path to your TPT-installation and the compiler in the make file. 

The example is based on Crc8_J1850/Crc8_J1850.c at master · II43/Crc8_J1850 · GitHub but  0xFF was used as initial value and as final XOR, which is not done in the example. The code works if the last 8bits of the message are supposed to be the CRC. The code needs to be adapted if something apart from the last byte is used to store the CRC. Please review the code before using it.

2. You can enter hashtables to be used for the CRC calculation by clicking "CRC definitions". If you set the CRC definition to one of those hashtables, this table will be used to create the CRC accordingly.

Please Wait!

Please wait... it will take a second!