Writing your first toggle LED application with FRMD-K64F + KDS 1.1.0 + KSDK 1.0.0 Non-Processor Expert

Document created by Garabo Employee on Aug 15, 2014Last modified by Diana Torres on Feb 28, 2017
Version 2Show Document
  • View in full screen mode

This document provides the guidelines to create a toggle LED application in the FRDM-K64F by using the KDS 1.1.0 + KSDK 1.0.0 and Non Processor Expert usage. This is helpful to understand how to create a project for KDS that uses the KSDK.

 

This document is assuming that KDS 1.1.0 and KSDK 1.0.0 are installed under a Windows OS system.

 

  • After the installation of KDS the environment variable “KSDK_PATH” must be defined. Under “System Properties” go to “Environment Variables…” located in the “Advance” tab.
  • Add the new variable under “User variables…”. The name should be “KSDK_PATH”. The path is the same where by default the KSDK is installed. In this case the path is “C:\Freescale\KSDK_1.0.0”.

  • The KSDK patch must be installed before to proceed with any project creation. To do this click in “Help” menu and then “Install New Software…“ option.
  • Click in the “Add…” button and then “Archive” button. Look for the file “C:\Freescale\KSDK_1.0.0\tools\eclipse_update\SDK_1.0.0-GA_Update_for_Eclipse.zip” and click “Ok” button.
  • Select the “Eclipse Update for KSDK 1.0.0-GA” option from the options and then press the “Next” button.
  • Next step is to create a new KDS project. Go to “File>New>Kinetis Design Studio Project” option

  • Then give a name; easy one, to remember what it does. Then press “Next”
  • Chose the board to be used. In this case we are using the FRDM-K64F. Now press “Next”.

  • Check the "Kinetis SDK" check box. Make sure that "Processor Expert" is not checked.

  • Project is now created and it is ready to include the source code.

 

  • All the KSDK examples include the "board" folder. It is necessary to do the same for this new project. To add it just right click in the project just created and chose "Import".

  • Select "File System".

  • Look for the board folder in the following path: C:\Freescale\KSDK_1.0.0\boards\

 

  • Chose the C and H files only from the "frdmk64f120m" folder. Just like this:

  • Then the folder "frdmk64f120m" is added to the project structure.

  • Following is to add the KSDK library in the compiler. To add it you need to give a right click in the project and click in "Properties". Under "C/C++ Build" menu go to "Settings". Then click in "Miscellaneous" under "Cross ARM C++ Linker". If you did it correctly then you will see this:

    

  • Click in add object button   and add the library here. The default path is "C:\Freescale\KSDK_1.0.0\lib\ksdk_platform_lib\kds\K64F12\Debug\ksdk_platform_lib.a".

  • Now, let’s toggle an LED. It is necessary to include the boards.h file:

#include "board.h" 

 

  • A GPIO pins enum needs to be created. We are using the RGB connected to the PORTE, specifically the pin 26 (PTE26). The enum then should look like this:

enum _gpio_pins

{

kGpioLED4  = GPIO_MAKE_PIN(HW_PORTE, 0x1A),//PTE26

};


  • Make sure you are giving the pin 26 as hexadecimal value. In this case the 26 is 0x1A and that is the value we give as second parameter to the GPIO_MAKE_PIN macro.
  • Add the calling to the function hardware_init()a just after the variable definition in the main() function.
  • After this, now call the function that is necessary to configure the pin direction:

GPIO_DRV_SetPinDir(kGpioLED4, kGpioDigitalOutput); 

 

  • Finally, to write the desired value to the LED use this function:

GPIO_DRV_WritePinOutput(kGpioLED4, value); 

 

  • The entire should code looks like this:

#include "fsl_device_registers.h"

#include "board.h"

 

enum _gpio_pins

{

kGpioLED4  = GPIO_MAKE_PIN(HW_PORTE, 0x1A),//PTE26

};

 

static int i = 0;

 

int main(void)

{

short value = 1;    /* Write your code here */

hardware_init();

 

GPIO_DRV_SetPinDir(kGpioLED4, kGpioDigitalOutput);

 

/* This for loop should be replaced. By default this loop allows a single stepping. */

for (;;) {

 

for (i = 0; i<0xFFFFFF; i++)

{

}

 

value = value^1;

GPIO_DRV_WritePinOutput(kGpioLED4, value);

 

}

/* Never leave main */

return 0;

}

 

  • Compile and ready to test. See the green LED blinking in the FRDM-K64F board.

Attachments

    Outcomes