cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 MPU configuration register read-back ?

Ryan_Lee
Associate

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!

1 REPLY 1
Sarra.S
ST Employee

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.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.