Create MQX for KSDK Project From Scratch in IAR IDE

Document created by Daniel Chen Employee on Jun 9, 2015Last modified by Daniel Chen Employee on Jun 10, 2015
Version 2Show Document
  • View in full screen mode

CREATE MQX FOR KSDK PROJECT FROM SCRATCH IN IAR IDE

 

Note: ${KSDK_PATH} is used in this guide line to instead of path of KSDK source

(Example: C:/Freescale/KSDK_1.2.0/). This procedure was created for TWR-K64f120M

 

1     Create new workspace

                Open IAR  --> File  --> New  --> Workspace

               

2     Create new project

  • Project --> Create New Project  --> C  -> main --> OK

 

                  

  • Select project directory

                            

 

3    Add project lib to workspace

        Project  -->  Add Existing Projectthen select projects:

{SDK_PATH}/lib/ksdk_mqx_lib/iar/K64F12/ksdk_mqx_lib.ewp

{SDK_PATH}/rtos/mqx/mqx/build/iar/mqx_twrk64f120m/mqx_twrk64f120m.ewp

{SDK_PATH}/rtos/mqx/mqx_stdlib/build/iar/mqx_stdlib_twrk64f120m/mqx_stdlib_twrk64f120m.ewp

 

                      

 

4    Build All Lib project

                 

 

5    Setting Project

On the left workspace pane, right click on Mqx Project and select Options.

  • Setting General Options

        Select device:

                     

 

  • Setting C/C++ Compiler

         Add include file and define symbols for project at Preprocessor tab:

Additional include directories:

{SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug

{SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/config

{SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx

{SDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx_stdlib

{SDK_PATH}/platform/osa/inc

{SDK_PATH}/platform/CMSIS/Include

{SDK_PATH}/platform/devices

{SDK_PATH}/platform/hal/inc

{SDK_PATH}/platform/drivers/inc

{SDK_PATH}/platform/system/inc

{SDK_PATH}/platform/devices/MK64F12/include

{SDK_PATH}/platform/devices/MK64F12/startup

{SDK_PATH}/platform/system/inc

{SDK_PATH}/platform/hal/inc

{SDK_PATH}/platform/drivers/inc

{SDK_PATH}/platform/startup

{SDK_PATH}/platform/utilities/inc

{SDK_PATH}/examples/twrk64f120m

{SDK_PATH}/rtos/mqx/config

{SDK_PATH}/rtos/mqx/mqx/source/include

 

Defined symbols:

CPU_MK64FN1M0VMD12

TWR_K64F120M

FSL_RTOS_MQX

                       

  • Setting Linker option

          Use linker file in KSDK source:

            {KSDK_PATH}/platform/devices/MK64F12/linker/iar/MK64FN1M0xxx12_flash.icf

          Set stack/heap size and define __ram_vector_table__

__stack_size__=0x400

__heap_size__=0x400

__ram_vector_table__=1

 

           

 

              The project request three librarys: lib_mqx.a, lib_mqx_stdlib.a, libksdk_platform_mqx.a

 

{KSDK_PATH}/lib/ksdk_mqx_lib/iar/K64F12/Debug/libksdk_platform_mqx.a

{KSDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx/lib_mqx.a

{KSDK_PATH}/rtos/mqx/lib/twrk64f120m.iar/debug/mqx_stdlib/lib_mqx_stdlib.a

 

             MQX uses owner’s startup-code (boot.S), We need to override default program entry

                      

 

6     Create project template

Project structure and create group:

         Specific file for board in:

{KSDK_PATH}\examples\twrk64f120m\board.c

{KSDK_PATH}\examples\twrk64f120m\board.h

{KSDK_PATH}\examples\twrk64f120m\gpio_pins.c

{KSDK_PATH}\examples\twrk64f120m\gpio_pins.h

{KSDK_PATH}\examples\twrk64f120m\pin_mux.c

{KSDK_PATH}\examples\twrk64f120m\pin_mux.h

 

         BSP file in:

{KSDK_PATH}\rtos\mqx\mqx\source\bsp\bsp.h

{KSDK_PATH}\rtos\mqx\mqx\source\bsp\bsp_config.h

{KSDK_PATH}\rtos\mqx\mqx\source\bsp\init_bsp.c

{KSDK_PATH}\rtos\mqx\mqx\source\bsp\mqx_main.c

{KSDK_PATH}\rtos\mqx\mqx\source\include\mqx.h

 

         Config files in:

{KSDK_PATH}\rtos\mqx\config\common\small_ram_config.h

{KSDK_PATH}\rtos\mqx\config\common\verif_enabled_config.h

{KSDK_PATH}\rtos\mqx\config\board\twrk64f120m\user_config.h

{KSDK_PATH}\rtos\mqx\config\mcu\MK64F12\mqx_sdk_config.h

 

          Utilities files in:

{KSDK_PATH}\platform\utilities\src\print_scan.c

{KSDK_PATH}\platform\utilities\src\print_scan.h

{KSDK_PATH}\platform\utilities\src\fsl_debug_console.c

{KSDK_PATH}\platform\utilities\inc\fsl_debug_console.h

 

                                    

                       
 

 

7    Write code

The code below is used to turn on the LED and print out “hello world”.

#include "stdio.h"

#include "fsl_os_abstraction.h"

#include "board.h"

#include "fsl_debug_console.h"

 

#define MAIN_TASK        8

void main_task(uint32_t param);

const TASK_TEMPLATE_STRUCT  MQX_template_list[] =

{

   { MAIN_TASK, main_task, 0xC00, 20, "main_task", MQX_AUTO_START_TASK},

   { 0L, 0L,        0L,    0L, 0L,         0L }

};

 

void main_task(uint32_t param)

{

    LED1_EN;

    LED1_ON;

    PRINTF("Hello World\r\n");

    while(1)

    {}

}

 

 

 

 

8    Run example:

  • Build project:

                 

  • Select debug target

                   

 

- Set serial console 115200 baud rate, no parity, 8 data bits, 1 stop bit, without flow control

- Set project as active prior we run project

 

  • Run project

                       

 

  • See Led1 is On status and string “Hello World” is printed to screen

                          

Attachments

    Outcomes