2024-12-30 08:54 PM
Hi,
I wish to calc a CRC using the CRC peripheral for some byte data and am using TouchGFX which as I understand it also uses the CRC peripheral.
I tried using the CRC unit but I am not calculating the correct ethernet 32 bit CRC for my data. I suspect the intialisation of the CRC unit in TouchGFX projects is incorrect for the ethernet version of CRC peripheral, maybe its the endianess of the data or the polynomial used or some other factor.
The problem of course is that TouchGFX and my other processes run on threads so a thread-safe config mode change to the CRC registers seems quite challenging. It may be best to use a thread-safe algorithm as the data streams to be processed are fairly short.
At the moment it is more of an academic exercise as the Ethernet peripheral has a separate CRC unit so the network data is protected by the Ethernet CRC.
Is there a way of using the CRC unit with TouchGFX or is it more trouble than it's worth?
Solved! Go to Solution.
2024-12-31 05:31 AM
Hello @Garnett.Robert ,
The CRC peripheral needs to be correctly initialized with the appropriate polynomial, initial value, and data processing order (endianness) for your specific CRC calculation.by default CRC s CRC-32 (Ethernet) polynomial: 0x4C11DB7 is used. Since TouchGFX and other processes may use the CRC peripheral, ensuring thread safety is crucial.
This can be complex and may require disabling interrupts or using mutexes to protect the CRC configuration and calculation which may affect TouchGFX with all the added latency and may make your application cluttered.
Given the complexity of ensuring thread safety and correct configuration, it might be more practical to use a software-based CRC calculation algorithm. This approach avoids conflicts with the CRC peripheral and can be made thread-safe more easily and since you will be using it for small amounts of data it will not be very costly in execution time.
You can find libraries in c that implement CRC quite efficiently see CRC32 C or C++ implementation - Stack Overflow.
Regards
2024-12-31 05:31 AM
Hello @Garnett.Robert ,
The CRC peripheral needs to be correctly initialized with the appropriate polynomial, initial value, and data processing order (endianness) for your specific CRC calculation.by default CRC s CRC-32 (Ethernet) polynomial: 0x4C11DB7 is used. Since TouchGFX and other processes may use the CRC peripheral, ensuring thread safety is crucial.
This can be complex and may require disabling interrupts or using mutexes to protect the CRC configuration and calculation which may affect TouchGFX with all the added latency and may make your application cluttered.
Given the complexity of ensuring thread safety and correct configuration, it might be more practical to use a software-based CRC calculation algorithm. This approach avoids conflicts with the CRC peripheral and can be made thread-safe more easily and since you will be using it for small amounts of data it will not be very costly in execution time.
You can find libraries in c that implement CRC quite efficiently see CRC32 C or C++ implementation - Stack Overflow.
Regards
2024-12-31 02:43 PM
Hi STea,
That was my thinking to.. Thanks for the link. I will have a look at it and add it to my library.
Kind Regards
Rob