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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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

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.
    14154_14154.pngpastedImage_124.png
  • 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”.

14155_14155.pngpastedImage_127.png

  • 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.
    14156_14156.pngpastedImage_130.png
  • 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.
    14157_14157.pngpastedImage_133.png
  • Select the “Eclipse Update for KSDK 1.0.0-GA” option from the options and then press the “Next” button.
    14158_14158.pngpastedImage_136.png
  • Next step is to create a new KDS project. Go to “File>New>Kinetis Design Studio Project” option

14160_14160.pngpastedImage_146.png

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

14162_14162.pngpastedImage_152.png

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

14163_14163.pngpastedImage_155.png

  • 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".

14164_14164.pngpastedImage_158.png

  • 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:

14165_14165.pngpastedImage_161.png

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

14166_14166.pngpastedImage_164.png

  • 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:

     14167_14167.pngpastedImage_167.png

  • Click in add object button 14168_14168.pngpastedImage_170.png  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".

14169_14169.pngpastedImage_173.png

  • 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.
Labels (1)
Comments

Great work!

Hi Garabo,

I have a relatively clean install of KDS 1.1.0 GA and KSDK 1.0.0 GA.  When trying to add the library from location  "C:\Freescale\KSDK_1.0.0\lib\ksdk_platform_lib\kds\K64F12\Debug\ksdk_platform_lib.a", I don't have the library file or even the DEBUG folder.  Do I need to build a different project first?

Thanks and regards,

Norm

Hi Garabo,

I found my issue - I needed to build the KDS platform driver library per Appendix A of the Kinetis SDK K64 User's Guide.

Thanks for the great work!

Regards,

Norm

Hi Norman,

Right, the compilation of the library is missing in my document. I will try to update in the next revision of the document. Thanks for the heads up!

Best Regards,

Garabo

hello Garabo,

I do refer to your design ,

while ,when i build ,it errors  ,

pastedImage_0.png

please help me

Waiting for your answer

Thank you !

Alice

Hi, Garabo,

My problem is resolved


Alice

Good to hear, What was the issue?

Regads,

Garabo

Great!!

Could you now write a tutorial about a new project GPIO with Processor Expert and/or MQX for KDS?

i have added the headers properly to inclues but still getting this errors everytime,

http://oi62.tinypic.com/n14ff7.jpg

plz help

Hi Kane,

Please try to compile the KSDK library. These errors are cause by two issues:

-KSDK lib is not compiled

-KSDK library is not added to the in the linker setting: 14167_14167.png

I hope this solved the problem

Best Regards,

Garabo

Hi Jose,

Let me work on that and hopefully have it ready in a few weeks.

Best Regards,

Garabo

No ratings
Version history
Last update:
‎08-15-2014 10:37 AM
Updated by: