This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0G3507: __WFI() function

Part Number: MSPM0G3507

Tool/software:

hii there

      while writing any code is it necessary to write a __WFI() function?

should I write like this?
   

int main()
{
    while(1)
    {
        if(flag == true)
        {
            transmit_msg();
            flag = false;
        }
    }
}
void IRQ_Handler(void)
{
    flag = true;
}
  • _WFI() is only needed if you want to pause the main thread  and let the  interrupts do all the work.

    Your code here is the most interrupt safe, since IRQ handler gets in and out quickly. Note that "flag" should be volatile. However, if you have a lot of time between interrupts, it is perfectly fine to call transmit_msg() in the handler.

  • The WFI or WFE functions are wait for interrupt/event and like Keith says it will pause the main thread and put the CPU into the low-power mode you have set.

    Regards,
    Luke