Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

if you have an OS, yes


You don't need an OS to do more advanced or efficient sleeping. You could have one of the timer peripherals generate an interrupt on a regular basis, and then put the chip in a lower power sleep mode in between interrupts.


Isn't that what an OS would do, essentially?


Yes, probably! But you can do it yourself without one.

Here is an example in C using libopencm3, that uses timers to trigger an interrupt used to flash LEDs https://github.com/libopencm3/libopencm3-examples/tree/maste...


that is basically a mini-os :)


You can set up a wakeup interrupt using a timer by moving a few values into a few registers. It doesn't require anything like an OS. Even tiny 8-bit microcontrollers can do this.


Sure, but putting the chip to sleep is one instruction, and programming the timer interval is only about a dozen instructions. So you don't really need an OS in this context.


There is a blurry line on the edges of "library" and "OS"; most people would put this particular example on the "library" side.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: