HAL CRC Overview

Introducing CRC

group CRC_Introduction

The CRC hardware abstraction layer provides a set of APIs to configure and control the CRC peripheral on STM32 microcontrollers.

The CRC (Cyclic Redundancy Check) calculation unit is used to compute a CRC code from 8-, 16-, or 32-bit data words and a generator polynomial.

Among other applications, CRC-based techniques are used to verify data transmission or storage integrity. Within the scope of functional safety standards, they offer a means of verifying flash memory integrity.

The CRC calculation unit helps compute a software signature at runtime, to be compared with a reference signature generated at link time and stored at a given memory location.

Module and files

The following diagram illustrates the CRC module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the CRC module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.

@startuml
<style>
componentDiagram {
   arrow {
      FontSize 8
   }
}
</style>

title CRC Software Component Diagram

package "HAL" {
    [HAL_CRC]
    [HAL_RCC]

}

package "Low Layer" {
    [LL_CRC]
    [CMSIS device]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_CRC] : HAL CRC API
[HAL_CRC] --> [LL_CRC] : LL CRC API
[HAL_CRC] -l-> [HAL_RCC]: HAL_RCC_CRC_EnableClock()
[LL_CRC] -l-> [CMSIS device]:CRC register def
[LL_CRC] --> [STM32_HW]: CRC registers R/W
@enduml

Configuration table

The following table lists the configuration defines for the HAL CRC module, specifying their locations, default values, and descriptions:

group CRC_Configuration_Table

Configuration inside the CRC driver

Config defines

Description

Default value

Note

PRODUCT

from IDE

NA

Example: STM32C5XX

USE_ASSERT_DBG_PARAM

from IDE

NA

Enable parameter asserts

USE_ASSERT_DBG_STATE

from IDE

NA

Enable state asserts

USE_HAL_CHECK_PARAM

from stm32c5xx_hal_conf.h

0

Runtime parameter check

USE_HAL_CRC_MODULE

from stm32c5xx_hal_conf.h

1

Enable the HAL CRC module

USE_HAL_CRC_CLK_ENABLE_MODEL

from stm32c5xx_hal_conf.h

HAL_CLK_ENABLE_PERIPH_ONLY

Enable HAL_CRC_CLK

USE_HAL_CRC_USER_DATA

from stm32c5xx_hal_conf.h

0

Allow user data usage