How to disable all interrupt on STM32?
Here are the practical ways to “disable all interrupts” on STM32 , depending on what you mean (mask CPU interrupts vs. stop peripherals from generating them). 1) Mask (disable) all CPU interrupts globally This is the most common meaning: prevent any interrupt handler from running on the Cortex-M core. CMSIS (portable) way # include "cmsis_gcc.h" // or core_cm*.h via your device header __disable_irq(); // masks IRQs (PRIMASK = 1) // critical section... __enable_irq(); // unmasks IRQs Direct register (same thing) __set_PRIMASK( 1 ); // disable IRQ // ... __set_PRIMASK( 0 ); // enable IRQ Notes This masks all “normal” interrupts (IRQ) . NMI (Non-Maskable Interrupt) and HardFault still happen. 2) Also stop Fault exceptions (more “everything”) If you also want to block most fault exceptions (MemManage/BusFault/UsageFault), use FAULTMASK . __disable_fault_irq(); // sets FAULTMASK = 1 // ... __enable_fault_irq(); // clea...