element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Freedom development platform
  • Products
  • Dev Tools
  • Freedom development platform
  • More
  • Cancel
Freedom development platform
Blog [FRDM-KL27Z + KDS + SDK] Tutorial: Toggling an RGB LED with Processor expert
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Freedom development platform to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bheemarao
  • Date Created: 8 Apr 2015 11:54 AM Date Created
  • Views 989 views
  • Likes 0 likes
  • Comments 0 comments
  • freedom-board
  • kinetis
  • kds+ksdk
  • led-toggling
  • frdm-kl27z
Related
Recommended

[FRDM-KL27Z + KDS + SDK] Tutorial: Toggling an RGB LED with Processor expert

bheemarao
bheemarao
8 Apr 2015

Here is a tutorial for toggling RGB Led’s on FRDM-KL27Z board using Kinetis Design Studio IDE and using Kinetis Software development kit (KSDK).


Before we begin make sure below requirements are there as setup


Required Hardware and Software:

 

  • FRDM-KL27Z Board loaded with MSD OpenSDA driver

(The firmware can be downloaded from FRDM-KL27-QSP)

  • Micro USB Cable
  • Kinetis Design Studio (v2.0.0)

(http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KDS_IDE)

  • Kinetis Software Development Kit for KL27Z (KSDK-v1.1.0)

(Download Link Kinetis SDK1.1.0 Standalone for the FRDM-KL27Z - Windows Installer )

 


Please refer to my blog for below actions: which was created earlier “Toggling LED without using Processor expert”


[FRDM-KL27Z + Kinetis Design Studio (KDS) + Software Dev Kit (SDK)] Tutorial: Toggling an RGB LED without Processor expert

 

 

Installing Kinetis SDK1.1.0 for KL27Z

 

Eclipse Update for Kinetis SDK1.1.0 (KL27Z)

 

Build the platform driver library

 

Creating New Project:


So let’s start in creating a new project using KDS + KSDK IDE

 

Open KDS IDE by double clicking the KDS icon present in your desktop:

It will ask for the Workspace, give the path of your choice and click ‘ok’

image

Next create a New project by clicking

 

File -> New  -> Kinetis Design Studio Project

image

Choose project name of your choice, i have given it as “KL27-LED-SDK-PE” and click Next.

image


You can select device either by ‘Boards’ or ‘Processor’ option, I am selecting the target device by processors as shown below:

image

You can see the Device part number of “MKL27Z64xxx4” click on “Next”


In the next screen you can find below options to be selected in Rapid Application Development window

Select the check box “Kinetis SDK”


And select the radio button “Absolute path” and browse for installed KSDK for KL27Z directory as shown below:

image

Proceed further and select the processor expert check box as below:

image

Next click Finish button and proceed further.


The project has been created with processor expert options included (i.e component window) and the project window looks like as shown below:

image

Next we need to add the component for gpio functionalities,


Select fsl_gpio from component library as shown:

image

As we know the LED’s have been connected to the board as shown below:


image

Click on fsl_gpio component to assign the 3 port pins as output connected to Led

image

 

Next select on Output pins > Output configurations option and press on ‘+’ button to increase the output pin numbers

image

Now select the first configuration and change the port pin setting to PTB-18 connected to Red LED, Rename this as ‘GPIOB18Red’


image

Similarly make the settings for the second one connected to PTB-19 port pin which is Green LED. Rename it as ‘GPIOB19Green’

image

We are assigning PTA13 for blue led and make the below settings:

image

In all the three settings we have assigned Output logic = 1 (since LED is active Low connection)

Next click on Input configuration option and deselect the check box as shown below:

image

Next click on initialization and deselect the input pin option check box as shown below

image

 

Now add the component wait() which is used to insert some delay routines in our program

image

As our project creation is by using processor expert we need not have to add any board related header folders to the project, those all required files are been taken care by processor expert itself.


These files have been generated in “Generated_Code” folder as shown below

image

Now to ensure our project is created without errors we will build it once

image


It builds with no error

Now we will proceed further by adding our code to toggle these led’s

 

You can see these LED’s are connected in active-Low connection, i.e common Anode, we should provide Low signal to port pins to glow a LED.

 

LED’s have been defined in the file called gpio1.c as shown below:

image

Now we shall toggle all the 3 LED’s one by one with some software delay() i.e blue is on for some time then blue+red is on for some time then blue+red+green is on for some time, this is one cycle of toggling pins and next time reverse happens i.e red+green is on (blue = off) and green is on (blue, red = off) then green also off (all the 3 led’s are off) this sequence loops back.

 

Navigate to fsl_gpio component and select GPIO_DRV_TogglePinOutput(); drag this function towards main.c and leave it to the shown position inside main();


image

Now we need to add the parameter for this function.

The parameter can be any of the led defined inside gpio.c


Below is my line of code to do this task


#include"Cpu.h"

#include "Events.h"

#include "pin_init.h"

#include "osa1.h"

#include "gpio1.h"

#include "WAIT1.h"

#if CPU_INIT_CONFIG

  #include "Init_Config.h"

#endif

/* User includes (#include below this line is not maintained by Processor Expert) */

 

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

/* Write your local variable definition here */

 

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

PE_low_level_init();

/*** End of Processor Expert internal initialization.                    ***/

 

/* Write your code here */

/* For example: for(;;) { } */

 

while(1){

 

GPIO_DRV_TogglePinOutput(GPIOB18Red);

WAIT1_Waitms(2000);

 

GPIO_DRV_TogglePinOutput(GPIOB19Green);

WAIT1_Waitms(2000);

 

GPIO_DRV_TogglePinOutput(GPIOA13Blue);

WAIT1_Waitms(2000);

 

}

 

/*** Don't write any code pass this line, or it will be deleted during code generation. ***/

/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

#ifdef PEX_RTOS_START

PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

#endif

/*** End of RTOS startup code.  ***/

/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

for(;;){}

/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

 

/* END main */


Explanation of the code:

 

GPIO_DRV_TogglePinOutput(GPIOB18Red);

 

This function toggles the red led and waits for 2 seconds as given in wait() function

WAIT1_Waitms(2000);

 

Similarly the case for the Green and Blue led


while(1){

GPIO_DRV_TogglePinOutput(GPIOB18Red);

WAIT1_Waitms(2000);

 

GPIO_DRV_TogglePinOutput(GPIOB19Green);

WAIT1_Waitms(2000);

 

GPIO_DRV_TogglePinOutput(GPIOA13Blue);

WAIT1_Waitms(2000);

    }

 

Inside the while() loop the led’s are been toggled one by one with delay

 

Now it’s time to clean and compile/Build the project

image


You can see the build output as shown below:

image


Now we need to setup for Debug configuration:

As a pre-requisite the board is loaded with OpenSDA provided in “FRDM-KL27-QSP.zip”

image

Select ‘GDB PEMicro interface Debugging’ and double click or right click and select ‘New’

 

You can see a default name as project name as shown below: make sure under ‘Main’ tab C/C++ application there is *.elf file name of your project.

image

Next click on Debugger tab check the interface is selected to OpenSDA and port is assigned as shown below

image

(make sure you have connected the board to PC via USB mini connector to “Open SDA” J-13 jumper of the board)

 

Now you can see the Debug window opens ready for single stepping or Running the project as shown:

image

Click on Resume button or press ‘F8’ button for executing the project.

 

You can see the output as shown

image


Attached is the video recording of the project execution.


You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


And i have enclosed the project folder for quick view and execution.


And also you can directly check the execution by programming the *.srec file to the board

 

Happy Toggling image  image image

Attachments:
KL27-LED-SDK-PE.rar
KL27-LED-SDK-PE.srec.zip
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube