Tuesday, June 9, 2015

Getting started with ARM Cortex M4 - working with Freescale FRDM-K22F

I’ve a Freescale FRDM-K22F development platform and we’ll setup the workspace for working and debugging. A prerequisite to this is to have the groundwork established as mentioned in my previous post – “Getting started with ARM Cortex M4 - setting up the work space”.

PART A – Running out of box demos
1.       Download and install the mbedOpenSDAv2.1 USB drivers found at

2.       Plug in a USB cable (standard micro USB cable) from a USB host to the OpenSDAv2.1 Micro-AB USB connector (J5). The FRDM-K22F will be powered by this USB connection. FRDM-K22F comes with the mass-storage device (MSD) Flash Programmer OpenSDAv2.1 Application preinstalled. It will appear as a removable storage drive with a volume label of MBED. The MSD Flash Programmer also includes a USB virtual serial port which requires an .INF file for proper installation in Windows. The necessary .INFfile is available in the mbedOpenSDAv2 .1 USB drivers (Step 1).

3.       Determine the symbolic name assigned to the FRDM-K22F virtual serial port. To do this in Windows, open Device Manager and look for the COM port named “mbedSerial Port”. My device is assigned the port 5.


4.       Open the serial terminal emulation program of your choice. I use Putty.

5.       Select the Connection Type as “Serial”. Set the com port as per step 3 and Speed(baud rate) to 115200. Hit Open.


6.       Press the any key on the keyboard or the SW3 pushbutton on the board to display the following message:
Select from the following menu:
 I. Bubble level –Single axis level using the red and green LEDs to indicate when the board is unlevel.
 II. eCompassdemo –Compass using the combined magnetometer and accelerometer to indicate the heading of board in reference to magnetic north.
III. USB CDC demo –Second serial terminal. (For additional details on the driver installation, refer to the instructions on the next page.)
IV. Metal Detector demo –Metal detector demo that indicates the direction and distance to a foreign metal object using the variable LED brightness as the indicator.
V. Stopwatch demo –Uses the real-time counter (RTC) to implement a stopwatch with 1/100th of a second precision.
VI. Air mouse demo –USB mouse using the accelerometer to determine where/how to move the cursor

7.       Enter a number key (1–6) on the keyboard to run each option from the Quick Start Demo. Further information will be displayed on the terminal as the demo runs.

PART B – Programming using the online mbed compiler
All ARM mbed enabled devices can be programmed using the online “open mbed compiler”. This is a very easy to use tool for novices. Visit the following link and create a mbed online account.

Next use your login to open the mbed online compiler. The online tool automatically detects your development board. In the top-left corner, click on the import button to open up the import wizard. Select the first project, “mbed_blinky” and click import (on the top-right corner). This project will be imported into your Program Workspace. Select the program in the Program Workspace and click on the compile button to perform a compile and download the binary file. Once the binary file is downloaded, drag and drop it into the “mbed” Removable device which shows up in My Computer. Then press the reset button on the development board and release it. The “mbed_blinky” program will start to run.

PART C – Programming using the Kinetis Design Studio
Freescale provides its own set of software IDE for development using the prototype board. This IDE is called the Kinetis Design Studio. The Kinetis Design Studio IDE is a complimentary integrated development environment for Kinetis MCUs that enables robust editing, compiling and debugging of your designs. Based on free, open-source software including Eclipse, GNU Compiler Collection (GCC), GNU Debugger (GDB), and others, the Kinetis Design Studio IDE offers designers a simple development tool with no code-size limitations. Furthermore, Processor Expert software enables your design with its knowledge base and helps create powerful applications with a few mouse clicks. Additional and new device support is installed through the Kinetis Software Development Kit (SDK). KDS can be downloaded from the following link. You may have to register to be able to download.


After the KDS and its dependencies are installed, you’ll get to start directly programming using the editor and debug the hardware with the OpenOCD tool.

To develop a sample project, select File -> New -> Kinetis Project. Give the project a name and click Next. Select Boards -> Kinetis -> FRDM-K22F and hit Finish.


Now, everything is good to go and you can start building code.

No comments:

Post a Comment