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

cancel
Showing results for 
Show  only  | 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:

https://community.freescale.com/docs/DOC-330183

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.

pastedImage_2.png

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

pastedImage_34.png

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

pastedImage_35.png

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

pastedImage_36.png

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.

pastedImage_0.png

pastedImage_1.png

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.

pastedImage_0.png

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:

<install_KSDK_1.3.0_path>\doc

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.

pastedImage_22.png

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

pastedImage_35.png

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

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

/* Enable clock for PORTs */

CLOCK_SYS_EnablePortClock(PORTA_IDX);

CLOCK_SYS_EnablePortClock(PORTE_IDX);

//Initializes GPIO driver

GPIO_DRV_Init(switchPins, ledPins);

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

while(1)

{

//  check if SW2 is pressed

if(GPIO_DRV_ReadPinInput(kGpioSW3) == 0)

{

GPIO_SW_DELAY;

GPIO_DRV_TogglePinOutput(BOARD_GPIO_LED_BLUE);

}

}

pastedImage_0.png

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)

GPIO

6. Build and debug the project.

Enjoy...

Comments

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.

No ratings
Version history
Last update:
‎02-03-2016 03:00 PM
Updated by: