Freescale FRDM-KL25Z & Kinetis Design Studio

Not so long ago, I picked up a Freescale FRDM board from Farnell purely because I had never worked with one before and wanted to give it a try. While browsing, I came across the KL25Z which looked like a perfect entry model at a very reasonable price.

FRDM-KL25Z

What is it ?

The Freescale Freedom KL25Z or FRDM-KL25Z is a low cost development board, featuring a Kinetis L series microcontroller, built on the ARM Cortex-M0+ core.

The board features:Screen Shot 2015-04-15 at 21.31.51

  • max operating frequency of 48MHz
  • 128KB of flash memory
  • full-speed USB controller
  • plenty of analog and digital peripherals
  • Arduino R3 compatible pin layout
  • onboard interfaces such as:
    • RGB LED
    • 3-axis accelerometer
    • capacitive touch slider
    • push button

It is also the first board to feature Freescale’s open standard embedded serial and debug adapter or OpenSDA, which offers serial communication, flash programming and run-control debugging.

Even though the board was launched in late 2012, it is still very popular today due to the availability of a lot of content online.

What’s in the box ?

IMG_6335Well, not so much actually. The packaging is rather basic but good looking and is generic enough to be used for other FRDM boards, which is nice.

The box contains two things:

  • FRDM-KL25Z board
  • a quick reference card

It’s a bit of a pity that no USB cable is provided, but as someone who is regularly playing with other dev kits, it was no problem to find one. Another thing to note is that the I/O pins are not populated with header pins, nor is the coin cell battery holder.

The kit can be obtained for a bit less than 15EUR from Farnell, which is a totally acceptable price point for anyone looking to get started with something new.

Out of box demo

By default, the board comes with a program showcasing some of the onboard components:

  • an RGB LED
  • a touch slider
  • an accelerometer

The program first cycles through some colours on the RGB LED and then changes colour based on data from the accelerometer. The brightness of the LED can be changed using the touch slider.

Kinetis Design Studio

Kinetis Design Studio (or KDS) is a freely available IDE for Kinetis MCUs, which can be downloaded from the Freescale website. It is based on opensource software like Eclipse, GCC, GDB and others. Unfortunately for me, downloads are only available for Windows and Linux, not OSX. Not a big problem using virtual machines, but not ideal.

KDS download links can be found here. Note that you will need to register before being able to download the IDE.

Installation

As stated earlier, there is no OSX download available. I proceeded by installing KDS in a virtual Windows XP environment.

The installation took a couple of minutes and right at the end, and error was reported. I ignored the error and proceeded ti start the IDE. Starting the IDE for the first time took some time to set up the workspace and so on and once done, it was ready for a first program.

Screen Shot 2015-04-15 at 20.41.25 Screen Shot 2015-04-15 at 20.41.52

Drivers

Using the board straight out of the box, it wouldn’t show up in the debugger configuration interface, even though Windows detected the device and installed the drivers.

Opening one of the html pages on the KL25Z drive that appears when the board is plugged in, an overview of software versions is provided. I searched for my issue online and verified if no new versions were available.

noport versions

I found that my board wasn’t running the latest version of the Bootloader (1.09 vs 1.11) and that no applications was installed. After upgrading the bootloader and installing the debug application, which is done by putting the board in bootloader mode (holding reset button while powering on the board) and dropping the upgrade files on the BOOTLOADER drive, the board was listed in the debugger configuration.

Screen Shot 2015-04-15 at 21.34.55 Screen Shot 2015-04-15 at 09.00.34

Usage

Having worked mainly with Arduino and Raspberry Pi before this, the IDE needed some getting used to. After some exploring and trying things out, I managed to get started on my first program.

First program

The “Hello World” of electronics: flashing an LED. In this particular case, I tried to light the RGB LED in different colours. As I was not familiar with the syntax, it took some time before I figured it out. The more I’ll experiment with the board, the easier things should go in the future.

To start, I created a new project, gave it a name, selected the correct processor and enabled “processor expert mode”. You can follow the steps in the screenshots below:

Screen Shot 2015-04-20 at 19.37.25 Screen Shot 2015-04-20 at 19.38.10

Screen Shot 2015-04-20 at 19.38.24 Screen Shot 2015-04-20 at 19.38.36

Once the new project is created, it is possible to drag in components to control. I’ve found two ways to control the RGB LED: either configuring the BitIO_LDD component from scratch or using the predefined FRDM_KL25_LEDRGB components. Using the predefined components will ensure among other things that the correct pin is used as an output.

Using the predefined components, some fields are not editable. If needed, they can be edited by switching to “advanced” mode.

Screen Shot 2015-04-20 at 19.47.37 Screen Shot 2015-04-20 at 19.48.37

When using the BitIO_LDD component, use following pins to control the RGB LED:

  • RED: PTB18
  • GREEN: PTB19
  • BLUE: PTD1

Once the components have been defined, they can be accessed from the code. This can be done with following commands in the “main.c” file, assuming the component for the red LED has been called “RED”:

To be able to blink the LED however, some form of delay is required. It seems there is no “sleep” or “delay” function by default in KDS. An external component called “WAIT” needs to be loaded, which comes bundled with a bunch of other components. The bundle can be downloaded here.

Once downloaded, extract the zip file and import the resulting PEupd files using KDS.

Screen Shot 2015-04-20 at 20.11.21 Screen Shot 2015-04-20 at 20.13.41

After importing, the components should be available to use immediately. I double-clicked the “WAIT” component in order to be able to use it. The new code to cycle through the three colours and light up each for 500ms is as follows:

After compiling, the onboard LED is cycling through all three colours over and over again.

KL25Z-RGB

Conclusion

Aside from the minor driver problems to get the board properly detected by KDS, everything went rather smoothly. There is of course the learning curve of using a new IDE if not familiar with other Eclipse based versions, but that is to be expected.

I have only touched a fraction of what this board is capable of for this post, but I plan on gradually diving deeper into it and eventually build a project around it.

If you’re wanting to try and learn something new, this board is a great entry point to the Freescale FRDM ecosystem. The price is very reasonable and with the amount of content available, you should be up and running in no time.

Leave a Reply

Your email address will not be published. Required fields are marked *