Está en la página 1de 17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

Tutorial: Enlightning the Freedom KL25Z Board


Posted on September 7, 2012

8 Votes The schematics for the Freedom board is now available on the element14 Freedom Board site (you need to log into the element14 community first) as FRDM-KL25Z Schematics (SPF-27556_D).pdf (314.7 K)). So time to write a tutorial how to use the LED on that board. In FreeRTOS with GCC, Cortex-M0+ and Kinetis KL25Z Freedom Board and A Shell for the KL25Z Freedom Board I have used that board with an RTOS: FreeRTOS. But it is really easy to use that board without an RTOS (bare metal) too. In this tutorial Im providing step by step instructions to use the RGB LED on the Freedom KL25Z board with Processor Expert and the open source LED component.

Im using CodeWarrior which has the ARM gcc build tools integrated for the Kinetis family. This tutorial features the Freedom KL25Z board with the version 10.3 of CodeWarrior, but is applicable with minor changes for any other Kinetis board and as well for CodeWarrior for MCU10.2. Note: This post show s screenshots of the upcoming CodeWarrior for MCU 1 0.3 w hich is not publicly available yet, but w ill be soon. Additional Processor Expert Component Installation

In this tutorial Im using additional open source Processor Expert components which are not part of the CodeWarrior Eclipse standard distribution: LED: Universal LED driver Wait: Universal waiting functions

Both *.PEupd files can be downloaded from the above links. To import them into CodeWarrior, I use the menu Processor Expert > Import Pack age:

Im porting Processor Expert Package

Then I browse to the *.PEupd files and select them to import. Hint: it is possible to import multiple components in a single step w ith selecting multiple files to import. After importing the components, it might be necessary to refresh the components list. To make sure all Processor Expert Views are loaded, I use the menu Processor Expert > Show Views :

Show Processor Expert Views

After importing, the LED and Wait component should show up in the Alphabetical tab of the Component Library view:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

1/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

LED and Wait Com ponents

If not, a Refresh of the components might be needed:

Refresh Com ponents

Creating the Project I use the menu File > New > Bareboard Project:

File New to create a new project

Next, I need to specify a name for my project:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

2/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

Nam ing the project

Next, I select the MKL25Z128 as my device: Hint: I can use the filter field to at the top of the dialog to filter the devices. In MCU1 0.3 I can simply type kl25, w here in MCU1 0.2 I need *kl25* as filter text.

Selecting KL2 5Z1 2 8

Next, to select the debug connection. As the Freedom Board has the new OpenSDA on it, this is my choice:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

3/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

OpenSDA as Debug Connection

In the next dialog, nothing has (or can) be changed. the ARM GNU GCC is the only (and default) tool-chain for Kinetis L (Cortex M0+) family:

ARM gcc Build Tools

Next, I select Processor Expert for my project:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

4/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

Pressing Finish creates the project for me:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

5/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

CodeWarrior Projects View with Com ponents

In case the Processor Expert component are not shown, I need to open the components for the selected project:

Open Com ponents for Project

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

6/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

Note: Now in MCU1 0.3 the project view and the Processor Expert Components view are clearly separate. LED To add the LED component, I select it and use the Add to project context menu:

Adding LED Com ponent

Hint: instead of using the context menu, I can double click on the component to add it. I do this 3 times, one for red, blue and green color. As I have missing settings, they show up with an error marker in the Components view:

3 LEDs in Com ponents View

Im changing the settings in the Component Inspector for the three LEDs: 1. Changing the Component name: this is an arbitrary name, and is used for the generated driver source files (.c and .h file). I name it LEDR, LEDG and LEDB for the three colors 2. I specify a Field Name: this is an arbitrary name, and same name I used in the LDD (Logical Device Driver name) 3. As according to the schematics the cathode of the LED is connected to the microcontroller pin, I specify no for this property

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

7/17

23/12/12

LEDR Settings

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

Linking to GPIO_LDD According to the FRDM-KL25Z Schematics (SPF-27556_D).pdf, the RGB LED is connected to following pins: Red: PTB18 Green: PTB19 Blue: PTD1 The LEDs need to be linked to the a GPIO_LDD component. For this I click into GPIO LDD property and use the drop down box to add a new component for it:

New com ponent GPIO_LDD

This will create a new shared component:

Creating Shared Com ponent

As two of the LEDs are on the Port B (PTB18 and PTB19), I configure it as such. I specify the port (PTB) and press on the plus sign to add bit fields:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

8/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse


Setting up port and adding bit fields

Next I configure the pin as output, and mark it for auto initialization so I do not need to call the initialization of it in my application:

PTB1 8 and PTB1 9

The Field Name has to match the field name I used in the LED component. Hint: If I specify the optional Pin Signal name, then Processor Expert w ill document it in the list of pins used. As the green LED is on the same port, I simply link to it:

Green Led Settings

As the blue LED is on port D (PTD1), I create a new shared component for it:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

9/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

New shared com ponent for blue LED (PTD1 )

Similar to the other LEDs, I set up the properties for PTD1 and the blue LED:

Settings for Blue LED

With this, the blue LED settings look like this:

Blue Led

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

10/17

23/12/12
Wait Component

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

As I want to busy wait between the LED toggling, I add the Wait component to the project:

Adding Wait Com ponent

Generating Code Now I have all my components together, time to generate code. For this I use the toolbar button:

Generate Processor Expert Code

This generates the code for my components:

Generating Code

Adding LED Code The application main() is inside ProcessorExpert.c , where add my LED demo code:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

11/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

LED Code

Hint: An easy w ay to add code and function calls to components is to use drag & drop. Build I build the project with the menu Project > Build Project or using the hammer icon:

Building Project with Ham m er Icon

At this point there should be no problems, so the Problems view should just show empty:

Em pty Problem s v iew with no problem s

Debug To download and debug, I press the debug toolbar icon. An annoying thing in Eclipse is I first need to *select* the project first to select the right debug configuration: So I select the project, then hover over the icon to make sure my project is selected. Otherwise I use the small drop down of the debug toolbar icon to select the right configuration:

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

12/17

23/12/12

Starting Debugger

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

This will start the debugger, and I can use the toolbar items in the Debug view to step through my code:

debugging the application

Source Code The project I have created in above steps can be downloaded from this link. Summary The steps presented here are really generic, and work for many boards and microcontrollers, especially for the Kinetis family. All what I need to know is the information to which pin the LEDs are connected. With this it is very easy to create a bare board (without RTOS) application blinking LEDs. Happy enlightning

Share this: Like this:

Twitter

Facebook

Email

LinkedIn

Google +1

Like

Be the first to like this.

This entry was posted in Boards, Embedded Components, Kinetis, KL25Z Freedom Board, Processor Expert, Tips & Tricks and tagged Building, Debugging, Embedded Component, KL25Z Freedom Board, Processor Expert, Tips&Tricks by Erich Styger. Bookmark the permalink [http://mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/] .
30 THOUGHTS ON TUTORIAL: ENLIGHTNING THE FREEDOM KL25Z BOARD

Pingback: S-Record Generation with gcc for ARM/Kinetis | MCU on Eclipse Pingback: OpenSDA on the Freedom KL25Z Board | MCU on Eclipse Pingback: Tutorial: Accelerating the KL25Z Freedom Board | MCU on Eclipse Pingback: Tutorial: Freedom with FreeRTOS and Kinetis-L | MCU on Eclipse Pingback: Tutorial: Touching the Freedom KL25Z Board | MCU on Eclipse

Patrick Menter on October 2, 2012 at 18:04 said:

This is an excellent example, shows how to use CW 10.3 and Processor Expert both on a small easy to understand example.

Pingback: Tutorial: USB CDC with the KL25Z Freedom Board | MCU on Eclipse

Pawel on October 8, 2012 at 22:10 said:

Great! But OK board is super. The question is where to buy alone microcontroller? Is possible to buy in Poland?

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

13/17

23/12/12
Erich Styger

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

on October 8, 2012 at 22:15 said:

Hello, not sure, but you should be able to get it through Farnell or any other distributor. They should have a Presence in Poland.

smiffytech on October 10, 2012 at 03:33 said:

Have you changed the LED bean since you wrote this? Im not seeing the LED at all under the alphabetical list, but LOTS of what look like boardspecific LEDs including FRBD_KL25Z_LEDRGB_RED (and GREEN and BLUE.) I guess I should be using these logical device drivers?

Erich Styger on October 10, 2012 at 05:45 said:

No, the LED bean has not changed, but Freescale added their own LED LDD components now. So you could use these if you want, they are using a similar approach as my bean. My bean is universal (works for all architectures), while the Freescale LDD LED ones are only working for Kinetis and ColdFire+.

smiffytech on October 10, 2012 at 03:37 said:

Further to above, I have imported the Wait package, and cant see that in the list, either. This is CW 10.3, build ID 120924.

Erich Styger on October 10, 2012 at 05:46 said:

Maybe your component list has not been updated. It does it automatically for me (Windows 7). Can you try to right click on the Component Library view and use the Refresh menu? then it should show up.

smiffytech on October 12, 2012 at 02:29 said:

Ah, should have thought of that. I couldnt see any obvious way to refresh (didnt know about right-click.) Ive got this on a WinXP VM. As it happens, Id shut it down; now Ive fired it up again, its all there. I now have a copy of Win7 is there any benefit to moving over to that? (Both VMs have access to the CW workspace.)

Erich Styger on October 12, 2012 at 08:31 said:

Im using Win7 32bit and 64bit, but natively (no VM). I think that using Win7 vs XP there is no real benefit, apart of that all the new stuff is focusing on Win7.

smiffytech on October 12, 2012 at 07:33 said:

Ive got all this building just fine tried it on WinXP and Win7. HOWEVER (and its a big however) Im unable to get CW to see the board. Ive picked up and installed the latest PE Micro drivers but when I plug in the board (Ive tried two different ones) on both XP and 7, I get a thing popup which finds USB storage on there, but P&E Connection Assistant always comes up (No Device Available)

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

14/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse


even with re-connections and re-boots. I know this isnt an Erich Problem, but Im not entirely sure where I should be looking for help as P&E Micros support proved utterly useless when I had a similar problem with the Multilink for HCS08. (It took two lots of new drivers to fix that.) Any pointers as to a half-decent support channel would be most welcome! Im certainly stuck playing with 8-bit stuff for the time being. (And my TI Stellaris LaunchPad, but Im probably not allowed to say that here

Erich Styger on October 12, 2012 at 08:37 said:

The LaunchPad is a fantastic board! Freedom of speech (in good sense) is important to me can dig this out.

. I published a while back a how-to-

install tutorial in https://community.freescale.com/thread/93204, but looks with the migration to the new forum this is lost. I see if I

Pingback: Removal of Processor Expert for a Project | MCU on Eclipse Pingback: Tutorial: printf() and Hello World! with the Freedom KL25Z Board | MCU on Eclipse

luismgc on October 20, 2012 at 20:11 said:

Hello. I can see from the CPU component properties that the core clock is working at 20.97152 MHz in FEI MCG mode. With this configurtion, I believe the crystal is not used at all. The FRDM-KL25Z is advertised as being able to work up to 48 MHz. For this, the setting would have to be to use the PEE mode using the 8 MHz external crystal with 22pF capacitor load. Is this correct? I tried this setting but Processor Expert tells me that the max core clock is 20 MHz. Do you have any information on the settings to use the MCU at 48 MHz?. Is there any source code for the out-of-the-box project that comes preprogrammed? Thank you.

Erich Styger on October 21, 2012 at 08:48 said:

Hello, yes, 48 MHz are possible. Have a look at my other FRDM post which is using 48 MHz: https://mcuoneclipse.wordpress.com/2012/10/07/tutorial-usb-cdc-with-the-kl25z-freedom-board/ I hope this helps, Erich

luismgc on October 22, 2012 at 16:01 said:

Great. Thanks. I just received my Freedom board a few days ago and discovered this blog while searching for information. Havent looked at all the posts, but it looks great. Real good step-by-step instructions. Thanks for the reply. Ill take a look at the post.

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

15/17

23/12/12

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse


Pingback: Copy my CodeWarrior Project | MCU on Eclipse Pingback: Tutorial: Bits and Pins with Kinetis and the FRDM-KL25Z Board | MCU on Eclipse Pingback: Arduino Data-Logger Shield with the FRDM-KL25Z Board | MCU on Eclipse

Royce on December 2, 2012 at 17:14 said:

Hello, Im trying out my FRDM-KL25Z, and selected this tutorial as my 1st project. However, you have stopped short of explaining the debugging procedure. There are several settings upon clicking the debug button,when does one select a particular setting ? What are the right settings for this project? Some issues: 1. In your photo, hovering over the debug button shows the tip: Debug Freedom_LED_FLASH_OpenSDA. When I do the same (with the project selected) I just get Debug as the tool-tip. 2. When I try to debug anyway, I get an error message with a No device available message. However my board is connected, and I could drag other binaries to the board and run them. 3. After I do a build /build all, should I get some executable like bin/srec/s19 etc (not sure which one is the default)? But I cant see any. When and where are the produced ? Sorry if my questions are noobish but I have only used 8 bit MCUs & All this is new to me. Thank You.

Royce on December 2, 2012 at 18:04 said:

Well, I got point (2) sorted out from this thread: https://community.freescale.com/thread/301232 and http://mcuoneclipse.com/2012/09/20/opensda-on-the-freedom-kl25z-board/ This should really be made more clear by Freescale . it is not mentioned even in the Sample Code Package which I tried to use & had this same error threafter I found this blog. But Im still curious about (1) & (3). Thanks

Erich Styger on December 2, 2012 at 19:20 said:

about point 1: the hover shows the active debug configuration. In Eclipse, make sure you have selected the project root folder in the project view, then the debug icon will know which project to debug (this is one of the few Eclipse things which really is not done very well). So always select the project to make it active. If you just have Debug, this means that you do not have launched a debug configuration yet. Click on the small triangle on the right side of the debug icon and select the configuration you want. If the list is empty (Eclipse populates it with your history), select the sub menu Debug as > CodeWarrior Download. This should lead you to the correct configuration. As for point 3: this post explains how to generate S19 files with gcc: http://mcuoneclipse.com/2012/09/13/s-record-generation-withgcc-for-armkinetis/ Hope this helps, Erich

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

16/17

23/12/12
Erich Styger

Tutorial: Enlightning the Freedom KL25Z Board | MCU on Eclipse

on December 2, 2012 at 19:15 said:

Hello, looks like you have sorted out point 1 and 2: you need to load the Debug Application. For point 3: the output binaries are placed in the output folder as specified in the build settings. For KL25Z it should be a folder named FLASH. As for generating the S19 file: see this post: http://mcuoneclipse.com/2012/09/13/s-record-generation-with-gcc-for-armkinetis/ Hope this helps, Erich

Royce on December 3, 2012 at 11:06 said:

Thank you for your answers! I finally got my 1st project working on the board.

mcuoneclipse.com/2012/09/07/tutorial-enlighting-the-freedom-kl25z-board/

17/17

También podría gustarte