this post was submitted on 24 Jan 2024
568 points (97.3% liked)

Programmer Humor

19149 readers
1270 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] aksdb 26 points 7 months ago (2 children)

On microcontrollers that might be a valid approach.

[–] [email protected] 11 points 7 months ago (1 children)

I've written these cycle-perfect sleep loops before.

It gets really complicated if you want to account for time spent in interrupt handlers.

[–] aksdb 2 points 7 months ago

Thankfully I didn't need high precision realtime. I just needed to wait a few seconds for serial comm.

[–] [email protected] 1 points 7 months ago (1 children)

But then I gotta buy a space heater too...

[–] [email protected] 4 points 7 months ago (1 children)

Microcontrollers run 100% of the time even while sleeping.

[–] [email protected] 4 points 7 months ago (1 children)

Nah, some MCUs have low power modes.
ESP32 has 5 of them, from disabling fancy features, throttling the clock, even delegating to an ultra low power coprocessor, or just going to sleep until a pin wakes it up again. It can go from 240mA to 150uA and still process things, or sleep for only 5uA.

[–] [email protected] 3 points 7 months ago* (last edited 7 months ago)

Nah, Sleeping != Low power mode. The now obsolete ATmega328 has a low power mode.