element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Documents [FRDM-KL46Z - CW] Tutorial: Make it blink in 15min
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Freedom development platform to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: bheemarao
  • Date Created: 11 Jun 2014 5:09 AM Date Created
  • Last Updated Last Updated: 9 Aug 2023 12:07 PM
  • Views 4180 views
  • Likes 2 likes
  • Comments 0 comments
Related
Recommended

[FRDM-KL46Z - CW] Tutorial: Make it blink in 15min

This Project brings you with a quick step in blinking an LED on FRDM-KL46ZFRDM-KL46Z board using CodeWarrior.

 

The Freescale Freedom development platform is a set of software and hardware tools for evaluation and development. It is ideal for rapid prototyping of microcontroller-based applications. The Freescale Freedom KL46Z hardware, FRDM-KL46ZFRDM-KL46Z, is a simple, yet sophisticated design featuring a Kinetis L series microcontroller, built on the ARMRegistered CortexTm-M0+ core.

 

FRDM-KL46Z can be used to evaluate the KL46, KL36, KL26 and KL16 Kinetis L series devices. It features a MKL46Z256VLL4MKL46Z256VLL4, this device boasting a max operating frequency of 48MHz, 256KB of flash, 32KB RAM, a full-speed USB controller, segment LCD controller, and loads of analog and digital peripherals. The FRDM-KL46Z hardware is form-factor compatible with the ArduinoTm R3 pin layout, providing a broad range of expansion board options. The on-board interfaces includes a 4 digit segment LCD, a 3-axis digital accelerometer, magnetometer, capacitive touch slider, and ambient light sensor.

The FRDM-KL46Z features the Freescale open standard embedded serial and debug adapter known as OpenSDA. This circuit offers several options for serial communications, flash programming and run-control debugging.

 

Refer to the link for more details on Freedom board.

 

The features of the FRDM-KL46ZFRDM-KL46Z include:

  • MKL46Z256VLLZ4MKL46Z256VLLZ4 MCU (48 MHz, 256 KB Flash, 32 KB RAM, Low power, 100 LQFP package)
  • Dual role USB interface with mini-B USB connector
  • Open SDA
  • 4 digit segment LCD module
  • Capacitive touch slider
  • Ambient light sensor
  • MMA8451QMMA8451Q accelerometer
  • MAG3110MAG3110 Magnetometer
  • 2 user LEDs
  • 2 user push buttons
  • Flexible power supply options – USB, coin cell battery, external source
  • Battery-ready, power-measurement access points
  • Easy access to MCU I/O via Arduino Tm R3 compatible I/O connectors
  • Programmable OpenSDA debug interface with multiple applications available including:
    • Mass storage device flash programming interface
    • P&E Debug interface provides run-control debugging and compatibility with IDE tools
    • CMSIS-DAP interface: new ARM standard for embedded debug interface
    • Data logging application
    • Arduino R3 compatibility

Before we start on our project make sure the board is in Debug mode (refer to the blog how to load in Debug mode using OpenSDA)

          

Now that our board is loaded in Debug Let’s start on creating a CodeWarrior project to quickly demonstrate blinking LED on KL46 board.

 

A free version of Codewarrior can be downloaded following the link below in the Downloads section:

www.freescale.com/cwmcu10

 

The Evaluation version is a 30 days Limited version and the Special Edition is Code Size Limited version (64KB for Kinetis MCUs with an ARM Cortex-M0+ core and 128KB for the Kinetis MCUs with an ARM Cortex-M4 core)

 

 

Follow the below steps for creating the CW project:

 

Select File->New->Bareboard Project

image

Provide Project Name “Blink-it using CW” then click Next

image

Now select the MCU exist on our KL46 board it is “MKL46Z256”

Kinetis L Series-> KL4x Family->KL46Z(48 MHz) Family->MKL46Z256   then Click Next.

image

Select OpenSDA option to connect for this board for debugging and programming, then click Next

image

Then click Next to proceed further

image

proceed further by clicking Next

image

in Rapid application development do not select Processor Expert then click on finish.

I have created the project by name “Blink-it using CW” as shown below:

image

Now open “main.c” and add the below code to it.

#include"derivative.h"/* include peripheral declarations */

void delay(int itime);

 

int main(void)

{

         

SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;

 

PORTE_PCR29 = PORT_PCR_MUX(1);     

      

           GPIOE_PDDR |= (1 << 29);        

     

          for(;;) {     

             GPIOE_PTOR |= (1 << 29);     

             delay(1000);                            

        }

     

       return 0;

}

 

void delay(int itime){

   int icompTime = 0;

   for(icompTime=itime*1000;icompTime!=0;icompTime--){

   }

}

The line of code shown below is System Clock Gating Control Register 5 (SIM_SCGC5)and Enable clock for PORT E setting bit field PORTE

SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK

 

Next below line is Pin Control Register n (PORTx_PCRn) setting for PORTE, and Select GPIO as pin functionality on multiplexer setting field MUX=001

PORTE_PCR29 = PORT_PCR_MUX(1); 

 

The below line of code is Port Data Direction Register (GPIOx_PDDR) and Set GPIO direction set bit corresponding bit on the direction register for each port, set the bit means OUTPUT

GPIOE_PDDR |= (1 << 29);

 

In for() loop we are toggling the output LED connected to PortE29   

This can be found from Schematic of KL46Z board (http://www.element14.com/community/docs/DOC-54780/l/element14-presents-the-frdm-kl46z--a-freescale-kinetis-l-based-freedom-development-platform)

 

 

LED

KL46

Green (LED1)

PTD5

Red (LED2)

PTE29

          image

image

image

Now it’s time to clean and Build the project as shown:

image

You can then see project starts building as shown

image

Now Run the project as shown:

image

 

Now you can see the blinking of Red LED on KL46 board

Project created folder and Video output of this project execution is attached for reference.

 

image

 

Now we will modify our code to blink Green LED too (both Red and Green)

By referring to schematic we know Green LED is connected to port PTD5

 

#include"derivative.h"/* include peripheral declarations */

void delay(int itime);

 

int main(void)

{            

           SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK; // PORT E mask Red LED

    SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK; // PORT D mask connected to Green LED

  PORTE_PCR29 = PORT_PCR_MUX(1); // PORT E MUX    

PORTD_PCR5 = PORT_PCR_MUX(1); // PORT D MUX

           GPIOE_PDDR |= (1 << 29);  //      switching on RED LED 

           GPIOD_PDDR |= (1 << 5);  //      switching on Green LED

     

          for(;;) {     

             GPIOE_PTOR |= (1 << 29);  // Toggling RED LED after some delay

             GPIOD_PTOR |= (1 << 5);   // Toggling Green LED after some delay

             delay(1000);                            

        }

     

       return 0;

}

 

void delay(int itime){

   int icompTime = 0;

   for(icompTime=itime*1000;icompTime!=0;icompTime--){

   }

}

we can now see both LED's are blinking

 

Happy Blinking LED on KL46 board...imageimage

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

Attachments:
Blink it CW-KL46.rar
  • freescale
  • kl46
  • kinetis
  • freedom
  • Share
  • History
  • More
  • Cancel
  • 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