Functional Description
1602
SPRUH22I – April 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
Cortex-M3 Peripherals
Table 25-2. Memory Attributes Summary (continued)
Memory Type
Description
Device
Memory-mapped peripherals
Normal
Normal memory
To avoid unexpected behavior, disable the interrupts before updating the attributes of a region that the
interrupt handlers might access.
Ensure software uses aligned accesses of the correct size to access MPU registers:
•
Except for the MPU Region Attribute and Size (MPUATTR) register, all MPU registers must be
accessed with aligned word accesses.
•
The MPUATTR register can be accessed with byte or aligned halfword or word accesses.
The processor does not support unaligned accesses to MPU registers.
When setting up the MPU, and if the MPU has previously been programmed, disable unused regions to
prevent any previous region settings from affecting the new MPU setup.
25.2.4.1 Updating an MPU Region
To update the attributes for an MPU region, the MPU Region Number (MPUNUMBER), MPU Region Base
Address (MPUBASE) and MPUATTR registers must be updated. Each register can be programmed
separately or with a multiple-word write to program all of these registers. You can use the MPUBASEx and
MPUATTRx aliases to program up to four regions simultaneously using an STM instruction.
25.2.4.1.1 Updating an MPU Region Using Separate Words
This example simple code configures one region:
; R1 = region number
; R2 = size/enable
; R3 = attributes
; R4 = address
LDR R0,=MPUNUMBER;
; 0xE000ED98, MPU region number register
STR R1, [R0,#0x0]
; Region Number
STR R4, [R0,#0x4]
; Region Base Address
STRH R2,[R0,#0x8]
; Region Size and Enable
STRH R3,[R0,#0xA]
; Region Attribute
Disable a region before writing new region settings to the MPU if you have previously enabled the region
being changed. For example:
; R1 = region number
; R2 = size/enable
; R3 = attributes
; R4 = address
LDR R0,=MPUNUMBER
; 0xE000ED98, MPU region number register
STR R1, [R0,#0x0]
; Region Number
BIC R2, R2,#1
; Disable
STRH R2, [R0,#0x8]
; Region Size and Enable
STR R4, [R0, #0x4]
; Region Base Address
STRH R3, [R0,#0xA]
; Region Attribute
ORR R2, #1
; Enable
STRH R2, [R0,#0x8]
; Region Size and Enable
Software must use memory barrier instructions:
•
Before MPU setup, if there might be outstanding memory transfers, such as buffered writes, that might
be affected by the change in MPU settings.
•
After MPU setup, if it includes memory transfers that must use the new MPU settings.