logoalt Hacker News

echoangleyesterday at 4:05 PM2 repliesview on HN

What if my CPU doesn't have that? I don't think Atmel Microcontrollers do for example.


Replies

bluGillyesterday at 5:00 PM

Better CPU selection. Embedded almost always have power requirements and you need to put your CPU into a low power mode not a loop which is running fast. You can also design your hardware such that you can turn the power off completely in these cases (or perhaps reboot).

Now that I think of it, a different project (I worked just down the aisle, but I wasn't on it) solved a lot customer complaints by turning all the "while(1);" loops into blink an error code - which since it does IO is defined behavior. Which probably is the correct answer to your question - don't just spin doing nothing, spin in such a way that the user has a clue why nothing is working (and in turn you can find out and perhaps fix real world bugs)

show 1 reply
AMDmi3yesterday at 5:49 PM

AVRs have SLEEP instruction.