2022-07-05 07:18 PM
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?
2022-07-22 12:40 AM
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:
2022-07-22 09:08 AM
2022-08-07 05:14 PM
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
2022-08-09 01:26 PM
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.