From Zero to main(): Bare metal C (2019)
Ahh the SAMD21G18. Of all the chips to show up on HN today. This chip I know not half as much as I'd like to and half as much I wish I didn't have to.We ported a rarely heard of RTOS to this chip (TNEO), and one of the most difficult parts was running tickless with sleepable states. The difficulty (discovered only by blood, sweat, tears, wtf oscope moments, dumb luck, and a random comment found on some obscure forum, definitely not in the data sheets) was that accessing certain registers (in our case RTC.CNT) would cause the chip to go in to a different clock domain temporarily and suddenly take as much as 300 usecs to read. Just this line:    uint currentClock = RTC.CNT;

That's all it took. Whereas most store some register into some local variable took nanoseconds, this one took a long long time.My experience in this world of embedded chips, is that many of the tutorials you read do not deal with power consumption really. They assume that you're playing with a dev board. Or that your application has copious amounts of power. But if you live in a battery powered world, your entire game lies around navigating between sleep and wake states on the chip.