__disable_irq();// do something ...__WFI(); __enable_irq();Sounds impossible, but it is the way to do, all other version causes race conditions and are not reliable.