The great thing with the Freedom FRDM-KL25Z board is its compatibility with Arduino Shields: a great set of board available at very reasonable prices. I had my hands on the Adafruit Data Logger shield, and now it was time to use the original Arduino Motor Shield R3.
Category Archives: Embedded
Adding Symbols to the CodeWarrior Debugger
On the TWR-LCD, I’m using a USB MSD bootloader. In Programming part of flash I showed how to download and debug the application on top of the bootloader. But how to debug both the bootloader and the application? At the same time with CodeWarrior for MCU? The magic key is tell CodeWarrior to use ‘Other Executables’.
KL25Z and I2C: Missing Repeated Start Condition
I really hate this kind of stuff: I know it should work, but it does not. I’m loosing a lot of time (hours, days, even weeks) to track it down to the root cause. Yes, I create my own bugs. Yes, there are bugs in tools, sources, libraries and components. But what many might not believe: there are bugs in silicon too :-(. If you do not believe, here is one: there is a hardware I2C problem on the KL25Z used on the Freedom board. It worked in one project, but not in another.
❗ The silicon bug described here is present on many Kinetis devices, not only the KL25Z!
So if you are facing a problem where you read 0xFF or wrong values from the I2C bus with the KL25Z, here is probably why (and how to workaround it). The problem showed up with a modified version of the Freedom Accelerometer tutorial….
Debugging Hard Faults on ARM Cortex-M
It is as bad as this: my application stopped in an unhandled interrupt service routine:

That does not tell much. I’m using Processor Expert generated code, and with this all my ‘unhandled’ vectors are pointing the same handler:
Continue readingArduino Data-Logger Shield with the FRDM-KL25Z Board
One success factor of the Arduino platform is the broad availability so-called ‘shields’: hardware plugin-modules which extend the capability of platform. Shieldlist.org currently lists 288 different shields available! Clearly, Freescale wants to benefit from that ecosystem with the Freedom FRDM-KL25Z board which features Arduino compatible headers. Time to use the Freedom board with an Arduino shield :-).
Thumbs up with Assembly on ARM Cortex
Sometimes it is necessary to write an interrupt service routine in assembly language. This is the case as well for the ARM Cortex-M0+ which is found in the KL25Z on my Freedom board. But there is something important about the ARM Cortex architecture: Thumb Mode.
Thumb mode the ‘ARM way’ to reduce the code size with a reduced (16bit wide) instruction set. The ARM architecture can implement a ‘mixed’ mode, on a function level. To distinguish between ‘normal’ ARM functions and ‘thumb’ functions, the processor is checking if the LSB (Least Significant Bit) of a function pointer (or function call destination) is set. So a jump address of 0x410 is for a ‘normal’ function, while a function jump to the address 0x411 (even if the function is located at the address 0x410) denotes a ‘thumb’ function.
USB Component Splitted and Updated
Checking the download statistics of my Processor Expert components on http://www.steinerberg.com/EmbeddedComponents/, there is a clear winner: FSL_USB_Stack 🙂
It has been a while I presented that universal USB CDC component in this blog. The component has received a larger re-architecture, I wanted to support more than just USB CDC. For this, the CDC part is now present in a separate sub-component:
Optimizing the Kinetis gcc Startup
The GNU gcc tool chain integration in CodeWarrior/Eclipse MCU10.3 has a nice feature to show the code and data size of my application after linking (see this article how to enable this). So if I create an ’empty’ project with the wizard, get the code and data size without consulting the linker map file:
But wait! 2604 bytes of code for almost doing nothing? That’s not what I want! There are ways to get that puppy much, much slimmer. Down to 284 bytes .
How (not) to Secure my Microcontroller
There are several reports in the Freescale forums around having ‘secured’ the Freedom board. But what does ‘securing’ a board mean? And what does it mean if I get that ‘Device is Secure’ dialog?
There are different levels of protection you can find in many embedded microprocessors, and the terms might vary from vendor to vendor:
- Protect
- Secure
- Disable Mass Erase
Defining Variables at Absolute Addresses with gcc
Many compilers offer a way to allocate a variable at an absolute address. For example for the Freescale S08 compiler, I can place my variable at a given address:
unsigned char buf[128]@0x2000;
This is very useful (and needed) e.g. if the hardware (like USB) needs a buffer at given address. The advantage of the above (non-ANSI and thus not portable) syntax is that I can define a variable at an absolute address, without the need to allocate it in the linker.
I wanted to do something similar with gcc for Kinetis/ARM, and searched many forums on the internet. Obviously, I’m not alone with this question. The solution I have found comes close to what I use e.g. for the S08 compiler.





