HAL RAMCFG How to Use ¶
- group RAMCFG_How_To_Use
-
How to use the RAMCFG HAL module driver ¶
This module provides a set of APIs to manage each feature supported by the internal SRAMs:
ECC feature
This feature is supported by SRAM2. ECC monitoring supports the single error detection and correction and double error detection.
Use the HAL_RAMCFG_ECC_Enable() function to enable the RAMCFG ECC monitoring process in silent mode, i.e. no interrupt will be triggered, nor will a callback be sent upon an ECC error. User must rely on HAL_RAMCFG_ECC_GetInfo() function to monitor or/and check for ECC errors if any.
Use the HAL_RAMCFG_ECC_Enable_IT() function to start ECC error monitoring process in interrupt mode and to activate the latching error address. The following interrupts will be enabled and user will receive a dedicated callback upon an ECC error :
Single error interrupt,
Double error interrupt,
Double error interrupt redirected to Non-Maskable Interrupt(NMI).
If an interrupt occurs on the RAMCFG line, user can call the HAL_RAMCFG_IRQHandler() function to manage the interrupt for a given instance.
If the double error interrupt is redirected to NMI, user can call the HAL_RAMCFG_NMI_IRQHandler() function to manage the RAMCFG NMI interrupt for a given instance.
Use the HAL_RAMCFG_ECC_GetInfo() function to get the type, status and address of the last ECC error detected. The type can be :
No ECC error detected,
Single error,
Double error. The status can be :
ECC error not corrected,
ECC error corrected.
Use the HAL_RAMCFG_ECC_Disable() function to disable the RAMCFG ECC monitoring.
Write protection feature
This feature is supported by SRAM2. The SRAM1 is divided to 64 pages and SRAM2 to 64 pages with 1 KB granularity. Each page can be write protected independently.
Use the HAL_RAMCFG_EnablePageWRP() function to set the write protection for the given SRAM page(s).
Use the HAL_RAMCFG_EnableWRPByAddr() function to set the write protection for the given SRAM with start address and number of bytes.
Use the HAL_RAMCFG_IsEnabledPageWRP() function to check the write protection status of a page of the SRAM.
Use the HAL_RAMCFG_IsEnabledWRPByAddr() function to check the write protection status of a SRAM address.
There is no API to disable write protection as this feature can only be disabled by a global peripheral reset or system reset.
Any write access to a write protected area of the given SRAM causes a HardFault interrupt.
Erase feature
Each SRAM can be erased independently through its RAMCFG instance.
After a complete hardware erase, the given SRAM is set to 0 value.
Use the HAL_RAMCFG_MassErase() function to launch a hardware erase for the given SRAM.
SRAM information getter
Use the HAL_RAMCFG_GetLLInstance() function to get the selected RAMCFG hardware instance.
Use the HAL_RAMCFG_GetSRAMBaseAddress() function to get the selected RAMCFG SRAM base address.
Use the HAL_RAMCFG_GetSRAMSize() function to get the selected RAMCFG SRAM size.