In an IoT (Internet of Things, see “IoT: FreeRTOS Down to the Micro Amps“) project I’m using the Freescale KL15Z microcontroller. The nodes are moving around, and the board is using a special inductive charging ‘on the fly’ when nearby the charging station. The energy is stored in capacitors, so no batteries are needed. That worked very well, but some system failed: they need to quickly check sensor signals after power-up. Tracking down the problem, it was obvious that most of the systems failed because it took them too long to boot from the power-on reset. So I instrumented the application to toggle an LED so I can monitor what happens: It was over 400 ms after power-on! Yikes!
That did not make any sense to me, so I was suspecting something must slow down the startup somehow, as I have not seen this in the previous design, and it works well with a normal reset. It only failed with POR (Power-On Reset). Debugging is not easy, as I cannot have a debugger attached in my test scenario. Well, until I realized the problem (stupid me!): the startup time of the clock oscillator!
I have a 32 kHz low power oscillator on my board, and these oscillators are known (not to me until now 😦 ) for slow startup time. See this article which explains some of the aspects.
Changing the system to start from the internal reference clock instead of the external one showed a huge improvement: startup time in less than 3 ms, that’s what I would have expected 🙂 :
There is always something to learn ;-). So the solution for me is to start the microcontroller with the internal reference clock so I can make a fast signal checking. Then I can switch to the external clock later in the application flow, so doing clock switching: internal reference clock for fast startup, then switching to the external 32 kHz clock.
Happy Starting 🙂