ISB (Instruction Synchronization Barrier) flushes the processor pipeline so subsequent instructions are fetched under preceding configuration changes. On Cortex-M, use it after changing settings that affect execution, such as CONTROL, privilege level, or MPU configuration. Without it, prefetched instructions could still reflect the old settings and cause faults. section 5.2.3 section 5.5.2
ISB is not a substitute for a memory barrier. DMB orders memory accesses, while DSB ensures outstanding memory operations complete before execution continues. Volatile reads and writes alone do not provide these guarantees or flush the instruction pipeline. section 5.2.3
unsafe {
// MPU_CTRL register: 0xE000_ED94
// Alternatively accessible via cortex_m::peripheral::MPU
core::ptr::write_volatile(0xE000_ED94 as *mut u32, 0x0); // Disable MPU
asm::dsb();
// Configure MPU regions here...
core::ptr::write_volatile(0xE000_ED94 as *mut u32, 0x1); // Enable MPU
asm::dsb(); // Ensure enable write completes before ISB
asm::isb(); // Flush pipeline: subsequent instructions use new MPU config
}
This MPU example uses DSB after the enable write to ensure it completes, then ISB so subsequent instructions use the new configuration. The region configuration is left as a placeholder. section 5.5.2
In Rust firmware, prefer cortex_m::asm::isb() for the barrier. Inline assembly with core::arch::asm! is an alternative when the available intrinsics are insufficient. System-register operations can require privilege and may fault at the wrong privilege level. section 5.2.3 section 5.6 section 5.5.3
