diff --git a/hal/mpu/mbed_mpu_v7m.c b/hal/mpu/mbed_mpu_v7m.c index 5778e74739..d4cfbcf79d 100644 --- a/hal/mpu/mbed_mpu_v7m.c +++ b/hal/mpu/mbed_mpu_v7m.c @@ -45,7 +45,7 @@ MBED_STATIC_ASSERT( void mbed_mpu_init() { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); const uint32_t regions = (MPU->TYPE & MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos; if (regions < 4) { @@ -178,40 +178,40 @@ void mbed_mpu_init() (1 << MPU_CTRL_ENABLE_Pos); // Enable MPU // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } void mbed_mpu_free() { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); // Disable the MPU MPU->CTRL = 0; // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } void mbed_mpu_enable_rom_wn(bool enable) { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); MPU->RNR = 0; MPU->RASR = (MPU->RASR & ~MPU_RASR_ENABLE_Msk) | (enable ? MPU_RASR_ENABLE_Msk : 0); // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } void mbed_mpu_enable_ram_xn(bool enable) { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); MPU->RNR = 1; MPU->RASR = (MPU->RASR & ~MPU_RASR_ENABLE_Msk) | (enable ? MPU_RASR_ENABLE_Msk : 0); @@ -223,8 +223,8 @@ void mbed_mpu_enable_ram_xn(bool enable) MPU->RASR = (MPU->RASR & ~MPU_RASR_ENABLE_Msk) | (enable ? MPU_RASR_ENABLE_Msk : 0); // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } #endif diff --git a/hal/mpu/mbed_mpu_v8m.c b/hal/mpu/mbed_mpu_v8m.c index 7304c149b9..15225733ad 100644 --- a/hal/mpu/mbed_mpu_v8m.c +++ b/hal/mpu/mbed_mpu_v8m.c @@ -35,7 +35,7 @@ MBED_STATIC_ASSERT(MBED_MPU_ROM_END == 0x1fffffff, "Changing MBED_MPU_ROM_END fo void mbed_mpu_init() { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); const uint32_t regions = (MPU->TYPE & MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos; if (regions < 4) { @@ -127,40 +127,40 @@ void mbed_mpu_init() (1 << MPU_CTRL_ENABLE_Pos); // Enable MPU // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } void mbed_mpu_free() { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); // Disable the MCU MPU->CTRL = 0; // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } void mbed_mpu_enable_rom_wn(bool enable) { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); MPU->RNR = 0; MPU->RLAR = (MPU->RLAR & ~MPU_RLAR_EN_Msk) | (enable ? MPU_RLAR_EN_Msk : 0); // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } void mbed_mpu_enable_ram_xn(bool enable) { // Flush memory writes before configuring the MPU. - __DSB(); + __DMB(); MPU->RNR = 1; MPU->RLAR = (MPU->RLAR & ~MPU_RLAR_EN_Msk) | (enable ? MPU_RLAR_EN_Msk : 0); @@ -172,8 +172,8 @@ void mbed_mpu_enable_ram_xn(bool enable) MPU->RLAR = (MPU->RLAR & ~MPU_RLAR_EN_Msk) | (enable ? MPU_RLAR_EN_Msk : 0); // Ensure changes take effect - __ISB(); __DSB(); + __ISB(); } #endif