on
2021-11-16
2:19 AM
- edited on
2025-03-17
5:58 AM
by
Laurids_PETERSE
The MPU (Memory Protection Unit) is included in the Cortex-M4 and M7 based STM32 Microcontrollers (refer to specific product datasheets to confirm availability). The MPU can be used to make an embedded system more robust and more secure by:
This article shows how to enable and configure the MPU using the STM32CubeMX software.
The purpose of this article is to explain how to use STM32CubeMX to configure the MPU. For details about the MPU please refer to the Application Note (AN), Managing memory protection unit in STM32 MCUs - Application note.
As an example configuration, we will define three MPU regions following the example provided in the application note as shown below:
Note: All the terms in this table are explained in the application note as well as all the definitions and explanations.
The STM32H743AI microcontroller will be used as the target device. It uses an Arm Cortex-M7 core that embeds the MPU.
The MPU configuration is now complete. While this article shows how to configure the MPU for the STM32H743AI following the example table in the application note, the MPU is highly configurable and can be tailored to variety of application needs.
STM32H753xI - Datasheet
STM32H742, STM32H743/753 and STM32H750 Value line advanced Arm®-based 32-bit MCUs - Reference manual
STM32F7 Series and STM32H7 Series Cortex®-M7 processor programming manual
Managing memory protection unit in STM32 MCUs - Application note
STM32CubeMX - STM32Cube initialization code generator - STMicroelectronics
Hi community. I am new using ST MCUs and I have to say that I am very pleased.
I am planning to use memory protection unit (MPU) in my project. My MCU is STM32G031K8 but I cannot find how to activate this function with CubeMX. I would want to do the same as the example above:
In addition in the reference manual there is no much information about this function or the registers involved:
or in the datasheet
https://www.st.com/resource/en/datasheet/stm32g031k8.pdf
An I wrong? or maybe this function is not available for this MCU. According to this is link I can use this function but I am not sure.
Thanks for your help!
Hello @OAgui.1 ,
@ST AME Support NF should be able to help you.
Thank you,
Laura
Hello,
You are correct.
For STM32G0 you cannot configure the MPU from CubeMX, you can configure the MPU by code and here is an example from the STM32CubeG0.
C:\Users\xxxxx\STM32Cube\Repository\STM32Cube_FW_G0_V1.6.1\Projects\NUCLEO-G071RB\Examples\CORTEX\CORTEXM_MPU
BR
Nico
Thank you so much for your explanation.
Hello, how to config Static Ram, Flash Memory and LCD ? I'm trying config, but displaying message conflict NE2 and NE3....
As stated in the article itself that both CortexM4 and M7 based MCU has MPU. I am using STM32F439 which is M4 based MCU and I have verified from the datasheet that it has MPU. But still CubeMX doesn't show any option to configure the MPU. Please clarify. Thank you.