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
  • There is no penalty for entering a leaving standby mode. If you enter deeper sleep modes, though, there will obviously be a penalty associated with saving and restoring system state. But, no latency for standby mode at all.

    Entering and leaving standby mode should not affect the operation of any other peripherals as the system remains powered. It is only the core clock which is halted.

    Yes, you could implement a delay-based or polling-based solution but both of those options will consume more power as the processor will continue to run while waiting. Most people would not regard that as good practice in developing a system like this.

    One point, though, is that if there is any doubt that the interrupt you are waiting for will eventually happen, it is worth implementing some kind of watchdog timer which will interrupt and wake up the system after some maximum length timeout if nothing else has happened. Otherwise, y ou run the risk of the system never waking up if the interrupt you are waiting for never happens. This would be good defensive programming practice.

    Hope this helps.

    Chris

Reply
  • There is no penalty for entering a leaving standby mode. If you enter deeper sleep modes, though, there will obviously be a penalty associated with saving and restoring system state. But, no latency for standby mode at all.

    Entering and leaving standby mode should not affect the operation of any other peripherals as the system remains powered. It is only the core clock which is halted.

    Yes, you could implement a delay-based or polling-based solution but both of those options will consume more power as the processor will continue to run while waiting. Most people would not regard that as good practice in developing a system like this.

    One point, though, is that if there is any doubt that the interrupt you are waiting for will eventually happen, it is worth implementing some kind of watchdog timer which will interrupt and wake up the system after some maximum length timeout if nothing else has happened. Otherwise, y ou run the risk of the system never waking up if the interrupt you are waiting for never happens. This would be good defensive programming practice.

    Hope this helps.

    Chris

Children