O'Reilly logo

Embedded Systems Architecture by Daniele Lacamera

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming the MPU

The MPU of Cortex-M microcontrollers support up to eight different programmable regions. A function that enables the MPU and sets up all the regions can be implemented and invoked at the beginning of the program. The MPU registers are mapped in HAL libraries, but in this case, we decided to define our own version and access them directly:

#define MPU_BASE 0xE000ED90#define MPU_TYPE (*(volatile uint32_t *)(MPU_BASE + 0x00))#define MPU_CTRL (*(volatile uint32_t *)(MPU_BASE + 0x04))#define MPU_RNR (*(volatile uint32_t *)(MPU_BASE + 0x08))#define MPU_RBAR (*(volatile uint32_t *)(MPU_BASE + 0x0c))#define MPU_RASR (*(volatile uint32_t *)(MPU_BASE + 0x10))

In our example, we used the following defined bit-field value definitions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required