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

The other approach to delay's (keep in mind, that there is no other process to yield the CPU too) is to use a timer (a peripheral of the micro controller).

This would take a fair bit more code to configure the timer, and setup an interrupt to handle the timer.



How do multiple processes usually 'share' a timer?


Microcontrollers (assuming no RTOS in use), typically don't have multiple processes, they have the main thread of execution (which in the article is the entire program) and have interrupt routines that a run in response to an external event (in this case, the timer has expired).

Using the interrupt driven approach, can led to better performance both in CPU time (async communication with slower periphials etc) and battery life (sleep states).


by either having the timer fire regularly and have run code to figure out what needs to be done now, or having code to set it to the time to the next needed interrupt




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: