Skip to main content
Explorer
April 23, 2025
Question

STM32H7 MPU configuration register read-back ?

  • April 23, 2025
  • 1 reply
  • 546 views

Currently, I've used the MPU_Config function to set up memory protection for multiple regions.

I want to read back the configuration registers to verify the settings. However, after examining the HAL_MPU_ConfigRegion function in the stm32h7xx_hal_cortex.c driver file, I found that each region configuration's is written to the same register.

Upon reading the MPU->RBAR and MPU->RASR registers post - configuration, only the settings of the last region are retained.

I'm wondering if there's a way to read the configurations of all regions. If not, Could someone explain the reason for this operation?

Thanks!

    This topic has been closed for replies.

    1 reply

    ST Employee
    April 25, 2025

    Hello @Ryan_Lee

    The problem you're facing is because of how the MPU works. RBAR and the RASR registers are used to set up memory regions, but they can only handle one region at a time.

    When you use the function HAL_MPU_ConfigRegion to set up a region, the settings are saved in the RBAR and RASR registers. However, each time you set up a new region, these registers are updated with the new settings, replacing the old ones. That's why, when you check these registers, you only see the settings for the last region you configured.

    So, you should either read the registers right after setting each region or save the settings in another part of your code for later reference.