Working with FreeRTOS projects using KDS and KSDK 1.3 Project Generator tool

Showing results for 
Search instead for 
Did you mean: 

Working with FreeRTOS projects using KDS and KSDK 1.3 Project Generator tool

Working with FreeRTOS projects using KDS and KSDK 1.3 Project Generator tool

Hello all,

This document describes how to create a FreeRTOS project in KDS using the Kinetis SDK Project Generator tool.

If you are interested in how to Create a FreeRTOS project using KDS and Kinetis SDK Project V2.0 please check the below link:

In order to follow this document, first it is necessary to install:

Creating a new project using the Project Generator tool

Kinetis SDK Project Generator tool is a supplement to the KSDK. It is intended to provide users with a convenient method for generating KSDK based projects for their intended target hardware.

The KSDK Project Generator requires the user to install an instance of KSDK 1.2.0 or 1.3.0 before generating new projects.

The KSDK Project Generator requires operates on Windows, Linux, and Mac OSX.

1. Launch the Project Generator executable.


2. Introduce the Project Name and choose the board used. For this example it is used the TWR-K64F120M.


3. In order to generate a FreeRTOS project, click on the "Advanced" button.


4. Choose the operating system, in this case FreeRTOS, the IDE KDS and select Generate standalone project.


5. After that, click on "Advanced Generate" button to create the project.

Open the project in KDS

Every application/example created using the KSDK Project Generator tool has one associated working set description file which includes the path to the example project file and the dependent RTOS library project file.

Simply import that file into KDS working space.



At this point you should be able to build the library and the project created.

Developing a FreeRTOS with KSDK application

Operating System Abstraction layer (OSA) provides a common set of services for drivers and applications so that they can work with or without the operating system.

OSA provides these services: task management, semaphore, mutex, event, message queue, memory allocator, critical part, and time functions.

An easy method to create a task is using  the OSA_TASK_DEFINE macro and the function OSA_TaskCreate(). The macro OSA_TASK_DEFINE declares a task handler and task stack statically. The function OSA_TaskCreate() creates task base-on the resources declared by OSA_TASK_DEFINE.

The parameters for this function are:

  • The stack size in byte.
  • Pointer to the stack.
  • The stack size in byte.
  • Pointer to the stack.
  • Initial priority of the task: OSA supports task priorities 0∼15, where priority 0 is the highest priority and priority 15 is the lowest priority.
  • Pointer to be passed to the task when it is created.
  • If this task will use float register or not.
  • Pointer to the task handler.


NOTE: The disadvantage with this method is that task function can only create one task instance.

The project created using the Project Generator tool creates one  task (task_example) implementing OSA.

For more information about functions, macros and drivers please consult the Kinetis SDK v.1.3 API Reference Manual. This is located, after install Kinetis SDK, at the path:


GPIO Example

1. Add a new task named task_led. Add also a macro for OSA_TASK_DEFINE, the priority of the task and the prototype.


To initialize and start RTOSes, OSA uses abstract functions OSA_Init() and OSA_Start(). Call OSA_Init() after calling hardware_init().

2. Create the empty body of task_led


3. Add the following code initialization code for GPIO driver.

PRINTF("\nLED TASK is running \n");

/* Enable clock for PORTs */



//Initializes GPIO driver

GPIO_DRV_Init(switchPins, ledPins);

4. Now add logic to toggle a LED when a button is pressed.



//  check if SW2 is pressed

if(GPIO_DRV_ReadPinInput(kGpioSW3) == 0)







5. It is needed a delay for the push buttons debounce. In this case it is GPIO_SW_DELAY which is defines as follows:

/*Delay for Switch debounce*/

#define GPIO_SW_DELAY \

do \

{ \

uint32_t i; \

for (i = 0; i < 0x2FFFFF; i++) \

{ \

__asm("nop"); \

} \

} while (0)


6. Build and debug the project.



I'm using Project Generator 2.2, KSDK 1.3 to generate FreeRTOS project for TWL-POS-K81.

The Project Generator does not complete.

please advice.

Version history
Revision #:
1 of 1
Last update:
‎02-03-2016 03:00 PM
Updated by: