ARM Cortex-M0+ Interrupts and FreeRTOS

Murphy’s Law

“Anything that can go wrong, will go wrong”.

strikes again. Well, the modified version of it:

“Anything that can go wrong, will go wrong, but it will wait until it really, really goes wrong”.

It is always amazing to see that systems having a fundamental flaw, they can work for a long period. Only that on day X my application crashes. And when found the problem, I’m wondering how in the world it was *ever* working with that bug in it :-(.

Continue reading

Advertisements

Debugging Hard Faults on ARM Cortex-M

It is as bad as this: my application stopped in an unhandled interrupt service routine:

Cpu_Interrupt

Cpu_Interrupt

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 reading

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

Data Logger Shield on Top of Freedom Board

Data Logger Shield on Top of Freedom Board

Continue reading

USB CDC and SCI: Side-by-Side with the Freedom Board

In “A Shell for the Freedom KL25Z Board” I have presented an application which implements FreeRTOS, LED’s and a shell using the UART on the KL25Z over OpenSDA. So why not adding native USB CDC to the mix? Using both the USB and CDC with the same shell?

So what I have added is that the shell runs on both the SCI (over OpenSDA) and USB CDC (with the KL25Z). For this, the FSL USB CDC software stack is now part of the project:

Shell Project with USB CDC

Shell Project with USB CDC

Continue reading

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.

Continue reading

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:

FSL_USB_Stack with Sub-Components

FSL_USB_Stack with Sub-Components

Continue reading

Tutorial: Bits and Pins with Kinetis and the FRDM-KL25Z Board

In “Optimizing the Kinetis gcc Startup” I stripped down the fat of my startup code. Now time to add some useful things. And what does a microcontroller like the KL25Z on the Freedom FRDM-KL25Z board have: Pins! And this means I have bits to set and read :-).

FRDM-KL25Z Board

FRDM-KL25Z Board

Continue reading

Getting Help on Processor Expert Components

That might be an obvious thing for me, but recent questions of readers of my blog let me think that it is not that obvious: How to use a Processor Expert component? How to find example code?

There is the context menu entry ‘Help on Component’ on the component itself, both in the Components Library view and on the component inside the project:

Continue reading

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:

Console View with Code and Data Size

Console View with Code and Data Size

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 :mrgreen: .

Continue reading

SWD Debugging with the FRDM-KL25Z Board

The OpenSDA on the FRDM-KL25Z board is a cool feature: I do not need any external debugging device to program and debug my board :-). But my KL25Z custom board will not have that OpenSDA on it: first because it would add additional costs, and I do not see a way how I could use it for my board, see this forum discussion. I better start using a SWD/JTAG debugger for my Freedom board to have everything in place.

What I need to add to the black Freedom board is the SWD header:

SWD J6 (populated) and J11 (unpopulated)

SWD J6 (populated) and J11 (unpopulated)

Continue reading

How (not) to Secure my Microcontroller

There are several reports in the 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?

Device is Secure. Erase to unsecure?

Device is Secure. Erase to unsecure?

There are different levels of protection you can find in many embedded microprocessors, and the terms might vary from vendor to vendor:

  1. Protect
  2. Secure
  3. Disable Mass Erase

Continue reading

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.

Continue reading