Close

Optimized firmware build

A project log for Electronic Ornament 2025 with EFM8SB1 Sleepy Bee

This EFM8-based ornament is an improvement on my PIC16-based design from 2024

zachary-murtishiZachary Murtishi 04/13/2025 at 21:390 Comments

I went and improved on the firmware build I put together earlier today by reorganizing my program to make use of the sleep mode to save power during periodic inactive periods, much like my PIC16LF1823-based design was implemented. The last build used the Timer2 peripheral for timekeeping, which I used because it is much easier to access than the RTC registers (which require indirect memory access to read/write). The use of Timer2 made the use of sleep mode impossible, as Timer2 cannot wake up the CPU from sleep mode (only idle mode).

I disabled Timer2 as it would no longer be used for timekeeping - instead, I enabled the RTC timer and set the alarm function to periodically trigger an interrupt and wake the CPU from sleep. Like the previous PIC16LF1823 design, these intervals were set to the following:

In order to use the button to wake up the CPU from sleep mode, I enabled the port mismatch function for my button pin (P0.1) in addition to the existing use of the INT0 interrupt. This allows the button to wake the MCU from its sleep mode, much like how it works on my previous designs. This is required as only the port mismatch function can wake up the CPU from sleep mode.

The use of sleep mode seems to have paid off, as I am now recording only a 3.2uA current draw from the EFM8SB1 when the CPU is in sleep mode:

On the other hand, I recorded a 1.35 mA current draw from the EFM8SB1 when the CPU was in idle mode:

Seems like sleep mode results in power consumption nearly 422 times lower than the idle mode!

Discussions