2023-12-15 03:07 PM - edited 2023-12-15 04:42 PM
The Issue
Background
__HAL_RCC_CRC_FORCE_RESET();
__HAL_RCC_CRC_RELEASE_RESET();
__HAL_RCC_CRC_CLK_ENABLE();
ctx.handle.Instance->CR = ctx.regs.CR;
ctx.handle.Instance->POL = ctx.regs.POL;
__HAL_CRC_INITIALCRCVALUE_CONFIG(&ctx.handle, value);
__HAL_CRC_DR_RESET(&ctx.handle);
value = ~HAL_CRC_Accumulate(&ctx.handle, (uint32_t *)data, (uint32_t)size);
__HAL_CRC_INITIALCRCVALUE_CONFIG(&ctx.handle, ~0);
I would like to know how to correctly reinit the CRC after jumping from my bootloader to application as everything I have tried has failed?
Solved! Go to Solution.
2023-12-21 04:25 PM - edited 2023-12-22 06:17 AM
I have managed to resolve the issue.
1. Snapshot the state of the CRC peripheral on POR.
2. Snapshot the state of CR and POL register after HAL_CRC_Init().
3. Apply the snapshot from step 2 before calling HAL_CRC_Accumulate()
3. Apply the snapshot from step 1 after calling HAL_CRC_Accumulate()
Note you must apply the entire snapshot of the peripheral from step 1. Even if the register didn't changed. I observed that if I only reverted the changed registered back to their POR state it didn't work. I cannot say why this is though