Hardware CRC calculation on STM32
All STM32 MCUs has hardware CRC unit which can be used to speed up calculation, however there is only one CRC instance in STM32 and is not re-entrant. Rather than direct evaluation through function call, multi access of CRC unit needs to be managed. The CRC function shall support both SW and HW mode and provide three schemes
- Force SW mode. This is useful when background tasks requires CRC calculation but there is no time critical needs.
- Default HW mode, Switch to SW after timeout.
- Force HW mode. Be cautious that when HW CRC unit is on heavy task, force HW CRC calcuation would block.
Test result shows that HW CRC is 10x faster than SW CRC (no tables)
---------
STM32G071
---- Hardware CRC ----
Address: (nil)
Length: 65536
CRC16-XMODEM: A662 : 10800 us
CRC16-IBM: 4F5F : 10800 us
CRC24-NVS: 9FAA61 : 130000 us
CRC32-ETH: E5DF24A4 : 10800 us
---- Software CRC ----
Address: (nil)
Length: 65536
CRC16-XMODEM: A662 : 130000 us
CRC16-IBM: 4F5F : 110600 us
CRC24-NVS: 9FAA61 : 130100 us
CRC32-ETH: E5DF24A4 : 110600 us
---------
STM32H747
---- Hardware CRC ----
Address: (nil)
Length: 65536
CRC16-XMODEM: 3533 : 500 us
CRC16-IBM: 6104 : 500 us
CRC24-NVS: EB77B2 : 10200 us
CRC32-ETH: BCBDE067 : 500 us
---- Software CRC ----
Address: (nil)
Length: 65536
CRC16-XMODEM: 3533 : 10200 us
CRC16-IBM: 6104 : 9650 us
CRC24-NVS: EB77B2 : 10200 us
CRC32-ETH: BCBDE067 : 9600 us
由 Victor Chen 编辑于