cancel
Showing results for 
Search instead for 
Did you mean: 

Is halt behavior the same as wait except for clock interruption?

mchahn
Senior

I have used the wait feature before. I treat it just as if there is no wait. I have "while(true) wait;" in my main.c. (I only use interrupts, the code is pure interrupt-driven).

I need to use halt now. Can I use halt the same way? Will the interrupts continue the same and will peripherals continue the same except for the clock interruption?

4 REPLIES 4
Artur IWANICKI
ST Employee

Within wait mode only core is topped, while all of the peripherals continue their work and there is no clock reconfiguration.

In halt mode all clocks are stopped, so only asynchronous peripherals can wakeup the system (usually IO lines). You can find more within:

  • AN2857 for STM8S:

https://www.st.com/resource/en/application_note/an2857-stm8s-and-stm8a-family-power-management-stmicroelectronics.pdf

  • AN3147 in case of STM8L:

https://www.st.com/resource/en/application_note/an3147-power-management-in-stm8l-and-stm8al-stmicroelectronics.pdf

Thanks.
mchahn
Senior

I need more help. I coded the halt as directed. There is just a loop in main that waits for a signal variable that tells it to halt. Then a button on a pin interrupts to leave halt mode. If I comment out the halt then everything works including the button interrupt. But when in halt mode the interrupt code is not reached. I verified this by toggling a test pin in the button interrupt routine.

The weird thing is that if I attach my swim connector and start debugging, halt works fine. It even works after the swim is disconnected. But resetting the cpu by pulling the battery causes halt to stop working. I Both the swim and nrst signals are pulled up with 10k to the battery.

Here is my code ...

// at end of main.c
 // app is fully interrupt-driven for low power
 while (true) {
    if(halting) {
      halting = false;
      halted = true;
      // halt: clock stops everything until button interrupt
      halt();  // can't get out of halt ??
    }
    //else wfi();   // stop cpu until any interrupt
  }
}
 
// button interrupt in different file
@far @interrupt void handleButtonInterrupt(void) {
 
  tp_set;  // toggle test pin
  tp_clr;
 
  if(halted) {
    // button pressed while halted
    halted   = false;
   }
 }

Any help would be greatly appreciated

mchahn
Senior

I have been unable to get halt to work, even with my simple code. However, I have coded similar behavior by turning off the clock to all peripherals and then entering a wait-for-interrupt. If I understand the behavior correctly this reults in similar power consumption. I think the master clock continues to run but all others will be stopped. I have been unable see the power consumption with my test equipment except to know that it is under a milliamp so it might be quite low. It was 3.5ma with peripherals running.