Over a million developers have joined DZone.

Slow 32 kHz Oscillator Startup

DZone's Guide to

Slow 32 kHz Oscillator Startup

· IoT Zone
Free Resource

Download Red Hat’s blueprint for building an open IoT platform—open source from cloud to gateways to devices.

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!

413 ms for startup

413 ms for startup

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 :-) :

Startup with internal reference clock

Startup with internal reference clock


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 :-)

Build an open IoT platform with Red Hat—keep it flexible with open source software.


Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}