Create MQX for KSDK Project From Scratch in IAR IDE

cancel
Showing results for 
Search instead for 
Did you mean: 

Create MQX for KSDK Project From Scratch in IAR IDE

Create MQX for KSDK Project From Scratch in IAR IDE

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

                pastedImage_1.png

2     Create new project

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

                   pastedImage_6.png

  • Select project directory

                        pastedImage_7.png    

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

                       pastedImage_10.png

4    Build All Lib project

                  pastedImage_13.png

5    Setting Project

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

  • Setting General Options

        Select device:

                      pastedImage_17.png

  • 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

                        pastedImage_21.png

  • 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

            pastedImage_24.png

              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

                       pastedImage_27.png

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

                        pastedImage_32.png            

                       
 

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:

                  pastedImage_38.png

  • Select debug target

                    pastedImage_40.png

- 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

                        pastedImage_42.png

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

                           pastedImage_44.png

Version history
Revision #:
1 of 1
Last update:
‎06-09-2015 07:32 AM
Updated by: