Functional Description
1603
SPRUH22I – April 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
Cortex-M3 Peripherals
However, memory barrier instructions are not required if the MPU setup process starts by entering an
exception handler, or is followed by an exception return, because the exception entry and exception return
mechanism cause memory barrier behavior.
Software does not need any memory barrier instructions during MPU setup, because it accesses the MPU
through the Private Peripheral Bus (PPB), which is a Strongly Ordered memory region.
As an example, if all of the memory access behavior is intended to take effect immediately after the
programming sequence, then a DSB instruction and an ISB instruction should be used. A DSB is required
after changing MPU settings, such as at the end of context switch. An ISB is required if the code that
programs the MPU region or regions is entered using a branch or call. If the programming sequence is
entered using a return from exception, or by taking an exception, then an ISB is not required.
25.2.4.1.2 Updating an MPU Region Using Multi-Word Writes
The MPU can be programmed directly using multi-word writes, depending how the information is divided.
Consider the following reprogramming:
; R1 = region number
; R2 = address
; R3 = size,attributes in one
LDR R0,=MPUNUMBER ; 0xE000ED98, MPU region number register
STR R1, [R0,#0x0] ; Region Number
STR R2, [R0,#0x4] ; Region Base Address
STR R3, [R0, #0x8]; Region Attribute, Size and Enable
An STM instruction can be used to optimize this:
; R1 = region number
; R2 = address
; R3 = size, attributes in one
LDR R0, =MPUNUMBER ; 0xE000ED98, MPU region number register
STM R0, {R1-R3}
; Region number, address, attribute, size and enable
This operation can be done in two words for pre-packed information, meaning that the MPU Region Base
Address (MPUBASE) register contains the required region number and has the VALID bit set. This
method can be used when the data is statically packed, for example in a boot loader:
; R1 = address and region number in one
; R2 = size and attributes in one
LDR R0, =MPUBASE
; 0xE000ED9C, MPU Region Base register
STR R1,[R0,#0x0]
; Region base address and region number combined
; with VALID (bit 4) set
STR R2,[R0, #0x4] ; Region Attribute, Size and Enable
An STM instruction can be used to optimize this:
; R1 = address and region number in one
; R2 = size and attributes in one
LDR R0,=MPUBASE
; 0xE000ED9C, MPU Region Base register
STM R0, {R1-R2}
; Region base address, region number and VALID bit,
; and Region Attribute, Size and Enable
25.2.4.1.3 Subregions
Regions of 256 bytes or more are divided into eight equal-sized subregions. Set the corresponding bit in
the SRD field of the MPU Region Attribute and Size (MPUATTR) register to disable a subregion. The
least-significant bit of the SRD field controls the first subregion, and the most-significant bit controls the
last subregion. Disabling a subregion means another region overlapping the disabled range matches
instead. If no other enabled region overlaps the disabled subregion, the MPU issues a fault.
Regions of 32, 64, and 128 bytes do not support subregions. With regions of these sizes, the SRD field
must be configured to 0x00, otherwise the MPU behavior is unpredictable.