That aspect just doesn’t sit well with me. (A mode which potentially does not generate light.)
If I was working on low moonlight + high turbo I think I’d try to bring the voltage monitoring into the picture. In other words I’d scale my moonlight PFM freq down as battery voltage dropped. Even doing it very linearly seems better than not doing it at all. At least it would light up with a partially discharged cell! Am I missing something important?
Interesting stuff with the PFM. I don’t really understand the mechanism, there’s a lot to parse just staring at the few lines you use in the code vs the plethora of info in the datasheet. I do understand what’s happening though, thanks to your relatively clear code & comments (both here and in the code). I guess You’re making use of “TOP”?
I can rarely make heads or tails of registers. I suck at number system conversions, addresses, and notation. I can plug 0x08 into a HEX>BINARY converter and get 0000 0000 0000 1000, and I take it that the 4th bit (bit 3) has been set to 1. Actually pairing that up with the stuff from the datasheet…. I assume I should be looking at page 73, but again - I can’t understand the notation. The struck text is true, but I think I’ve got it now. I was missing that both bit 3 and bit 0 got set. So we are in “Mode 5” where we update OCRB at TOP and TOP is OCRA (all using Phase Correct). I know it’s pitiful, but I feel accomplished having finally gotten that worked out.
Thanks for doing the heavy lifting on this, it seems like a good advancement to me!
EDIT: For others trying to get a handle on this, I referred to sections 11.2.2 of the ATtiny13A datasheet (on page 60) as well as the chart at the top of page 73 and the little control register diagram in the middle of that page (so the top of section 11.9.2).