WFI Instruction

Hi,

I want to use the wfi instruction in my code. I'm sending a command to a module and wait for the reply.

I have configured UART communication with the module. Will it be good to use wfi() instruction? I know that it will turn  the cpu to power down mode.

Instead I can use some arbitrary delay, but the time taken for the reply is varying in nature.(.7 to 2 sec)

What if I poll the Interrupt flag? is there any alternate solution ?

Thank You.

Parents
  • You can exit the low priority interrupt handler, back to the main loop and execute WFI in your main loop. As you already know, this will place the processor into standby mode. It will execute no further instructions until an interrupt happens.

    Alternatively, you can set the SLEEPONEXIT bit, wither within the handler or before it is entered. When the handler exits, the processor will automatically enter standby mode and wait for an interrupt to restart execution.

    There is a paper I wrote on some of these techniques, based on a presentation from Embedded World 2015. You can find it here.

    Hope this helps.
    Chris

Reply
  • You can exit the low priority interrupt handler, back to the main loop and execute WFI in your main loop. As you already know, this will place the processor into standby mode. It will execute no further instructions until an interrupt happens.

    Alternatively, you can set the SLEEPONEXIT bit, wither within the handler or before it is entered. When the handler exits, the processor will automatically enter standby mode and wait for an interrupt to restart execution.

    There is a paper I wrote on some of these techniques, based on a presentation from Embedded World 2015. You can find it here.

    Hope this helps.
    Chris

Children