Tutorial: Using Eclipse with NXP MCUXpresso SDK v2 and Processor Expert

To me, software and tools are by far more important than the microcontroller. Because the silicon is a ‘one time kind of thing’, where the software has to be maintained and working over a longer time. And at least my software usually needs to be ported to a new device, so portability and available software and tools are critical to me.

The combination of MCUXpresso SDK (formerly Kinetis SDK) and Processor Expert is unfortunately not supported by NXP. But I have found a way to get them work together in a nice way, and this article is about making that combination possible :-).

SDKv2 Project with Processor Expert

SDKv2 Project with Processor Expert which is supposed not to work together

Outline

If you are not using Processor Expert or the NXP MCUXpresso SDK v2, then you can move on. Otherwise…. and if you are still curious about how things work in Eclipse: read on and I’ll tell you how to something like this in Eclipse: Using Processor Expert in a MCUXpresso SDK project which is supposed not to be possible 🙂 :

OK, to be 100% correct: It is not the ‘full’ or ‘native’ support of Processor Expert in a MCUXpresso project. But I show a way how the benefits of Processor Expert (code re-use, graphical configuration, software component packaging and redistribution) can be used even in a MCUXpresso SDK Eclipse project which are not natively supported by Processor Expert.

How to use FRDM-KL27Z Boards?

I believe one of the best-selling NXP Freedom boards is the FRDM-KL25Z:

Freshly Unboxed NXP FRDM-KL25Z Board

Freshly Unboxed NXP FRDM-KL25Z Board

It is inexpensive (~USD 15), has reasonable speed (48 MHz) with decent FLASH (128 KByte) and RAM (16 KByte). The students at my university love that board too. And a distributor at the Embedded World show in Nürnberg told me that he thinks this is because of Processor Expert and all the tutorials on McuOnEclipse :-).

But recently the university ordered FRDM-KL27Z boards for student projects instead of FRDM-KL25Z, because this should not make any difference, right? Well, it actually does: The FRDM-KL27Z is supported by the MCUXpresso SDK v2 only, and the MCUXpresso SDK v2 projects are not supported by Processor Expert. When students realized that, they wanted to return the boards because with Processor Expert it is much easier, simpler and faster to use the FRDM boards. So I offered that they can exchange the FRDM-KL27Z boards with the FRDM-KL25Z ones I have in my classroom inventor.

With the result that very fast I had a pile of FRDM-KL27Z boards which students did not want to use:

FRDM-KL27Z Boards

FRDM-KL27Z Boards

That triggered the idea: maybe there is a way to make these board usable with Processor Expert, so students would again love to have them in their projects?

Approach

In “Mother of Components: Processor Expert with NXP Kinetis SDK V2.0 Projects” I presented an approach how to use Processor Expert with the NXP/Kinetis SDK (now MCUXpresso SDK). That approach used two projects: a master and a slave project. I have now found a way which uses a single project: enabling Processor Expert for a SDK project and having the ProcessorExpert.pe XML file in a single project:

ProcessorExpert.pe

ProcessorExpert.pe

This article describes how to use Processor Expert for NXP SDK projects for which Processor Expert is not supported by NXP. Using that approach, it is possible to use ‘generic’ or ‘non-cpu’ components for the SDK. This approach allows carrying over many of the good aspects of Processor Expert as code re-use and power software configuration and distribution. In this article I’m using the NXP FRDM-KL27Z board with Kinetis Design Studio V3.2.0. I’m using Processor Expert components from the McuOnEclipse project.

The approach uses the following steps:

  1. Create a new SDK project or use an existing one
  2. Copy a Processor Expert .pe file into the project
  3. Ignore a few files generated by Processor Expert
  4. Use Processor Expert to configure the project and to generate the software and drivers.

Prerequisites

In this article, I’m using NXP Kinetis Design Studio v3.2.0 with the MCUXpresso SDK for the FRDM-KL27Z board, but certainly any other Eclipse version or SDK version could be used too. You need:

Creating a Project

You can use an existing NXP SDK project for Kinetis Design Studio (KDS) V3.2.0. Or create a new one. To create a new project, us the menu  File > New > Kinetis SDK V2.x project.

New SDK project

New SDK project

Create a normal project. I recommend to turn on all drivers, but not enabling FreeRTOS as the Processor Expert component for FreeRTOS is more capable. So have it set to ‘all drivers’ (so we do not need any drivers afterwards) and ‘none’ for RTOS (as we can use Processor Expert for this later).

New SDK project settings

New SDK project settings

Adding Processor Expert

Next, add a Processor Expert .pe file to the project. For this I create a ‘dummy’ project just to have a ProcessorExpert.pe file available.

I usually create a new (empty) Processor Expert project using the menu File > New > Processor Expert project. Select a processor which is supported by Processor Expert (e.g. KL25Z).

Select from the list of Processors (not from the list of Boards):

New Kinetis Processor Expert Project

New Kinetis Processor Expert Project

Select ‘none’ for SDK and turn on ‘Processor Expert’:

Processor Expert Project

Processor Expert Project

then copy the .pe file from the SDK project into the SDK project:

Copy Processor Expert File

Copy Processor Expert File

After that, the ‘dummy’ project is not used any more and can be deleted.

The .pe file is recognized by Eclipse as Processor Expert: We have enabled Processor Expert for the NXP SDK v2 project: 🙂

Processor Expert Enabled for SDK v2 Project

Processor Expert Enabled for SDK v2 Project

About the Processor

The project now shows the Processor Expert components and settings, although it is for the ‘wrong’ microcontroller/processor (e.g. KL25Z instead of the KL27Z).

Processor Expert Processor

Processor Expert Processor

Processor Expert thinks it is for the KL25Z, but we want to use it for the KL27Z SDK project. The ‘Cpu’ component kind of represents all the knowledge about the device (memory map, vector table, peripherals like UART, I2C, SPI, etc). So with such a Processor Expert enabled project, I use all components which do not depend on that information. So that works for pure software components like the RingBuffer or Utility component, or for any of the McuOnEclipse components I have enhanced with the capabilities to work with the SDK v2 API. This includes components like SDK_BitIO, Shell,  FreeRTOS. And the number of supported components is growing with the goal to port as many existing projects to the SDK v2 and beyond.

Ignoring Files

So I have a Processor Expert project for the KL27Z, and I can generate code for it, like for any normal Processor Expert project:

Generate Processor Expert Code

Generate Processor Expert Code

However, the non-matching files need to be ignored for the SDK project.

Processor Expert creates the following folders:

Processor Expert Generated Files and Folders

Processor Expert Generated Files and Folders

  • Documentation: here documentation files are generated.
  • Project_Settings: this contains the linker file and the startup code. The SDK comes with its own files, so we can ignore them.
  • Sources: this has the application event files (Events.c, Events.h) and the application main file (main.c). The SDK comes with its own files, so they should not be compiled.
  • Static_Code: contains low-level macros for the wrong microcontroller, so this folder has not be compiled with the SDK (should be ignored)
  • Genereated_Code: here all the driver source files are placed. Here most of the things apply to the SDK v2 project, but not all.

To exclude files from the build (so they are not part of the SDK project), use the context menu on the file/folder and enable ‘Exclude resource from build’ (menu Properties > C/C++ build > Settings > Exclude resource from build, see “Exclude Source Files from Build in Eclipse“):

Exclude from Build

Exclude from Build

Do this for the following folders:

  • Project_Settings
  • Sources
  • Static_Code
Excluded Folders

Excluded Folders

Alternatively, the generation for the ‘Project_Settings’ can be turned off in the Build options of the Cpu component:

Disabled Linker and Startup File Generation in CPU Properties

Disabled Linker and Startup File Generation in CPU Properties

Generated_Code

In the generated code, there are three files which are not matching the device of the SDK project. Exclude the following files from the build:

  • Cpu.c
  • PE_LDD.c
  • Vectors.c
Ignored files and folders

Ignored files and folders

Build and Next Steps

I can now generate code, build and debug the application:

Debugging SDK Application

Debugging SDK Application

So this is not much different from any other project. But now I have the power of Processor Expert enabled for the SDK v2 project, which is what I’m doing next: Using Processor Expert to extend the project to blink a LED (‘blinky’).

McuLibConfig Component

Using Processor Expert components with that project, they need to know that they shall work with the NXP MCUXpresso SDK. For this the McuLibConfig is added to the project: From the ‘Components Library’ add the component to the project and configure it to use the MCUXpresso SDK:

Adding McuLibConfig Component

Adding McuLibConfig Component

LED Component

Next, add a LED component to the project:

Adding LED Component

Adding LED Component

SDK_BitIO Component

By default, the LED component uses the normal Processor Expert BitIO component. Change it to use the SDK_BitIO component, available in the drop down for the ‘Pin’ settings:

Changing to the SDK_BitIO Component

Changing to the SDK_BitIO Component

This now uses a generic BitIO component which uses the SDK API:

Default SDK_BitIO Settings

Default SDK_BitIO Settings

Checking the schematics of the board, I can see that the Red LED is on PTB18 (GPIOB, PORTB, Pin 18):

Red LED Pin Settings

Red LED Pin Settings

With turning on the ‘Do Pin Muxing’ option, I don’t have to care about the muxing.

Enable the Clocks

The component cares about the muxing, but not about the clocks. So I have to add the following inside BOARD_InitPins(), otherwise I will run into a hard fault:

CLOCK_EnableClock(kCLOCK_PortB);
Enable Clocking

Enable Clocking

Wait Component

Because I want to delay the blinking of the LED, I add the Wait component which allows me to burn CPU cycles:

Adding Wait Component

Adding Wait Component

Initialization Code

In normal Processor Expert projects, the components get initialized in PE_Low_Level_Init(). For the SDK project, I have to call the Init functions in my code.

I include the component header files:

/* component header files */
#include "WAIT1.h"
#include "LED1.h"

Inside my code, I initialize the components:

/* initialize components */
LED1_Init();
WAIT1_Init();

Followed by the blinky code:

for(;;) { /* Infinite loop to avoid leaving the main function */
  LED1_Neg(); /* negate the LED */
  WAIT1_Waitms(500); /* wait for the given number of milliseconds */
}
Blinky Code

Blinky Code

Generate again Processor Expert code, build and debug the project, and I have a added a ‘blinky’:

Blinky with Processor Expert on FRDM-KL27Z

Blinky with Processor Expert on FRDM-KL27Z

🙂

Summary

While Processor Expert is not supported with NXP MCUXpresso SDK v2 projects, there is a way to add Processor Expert code generation to such projects. It adds re-use of software components and a way to graphically configure software and drivers. It works with ‘software’ components or components of the McuOnEclipse projects which have been enabled to be used with the SDK v2. With this, this approach closes a gap the NXP SDK v2 has created with no graphical driver or peripheral configuration.

An extended example project used in this article can be found on GitHub: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-KL27Z/FRDM-KL27Z_McuOnEclipseLib. It shows as well the subset of currently supported components and drivers which is growing and growing:

Example Set of SDK v2 Components

Example Set of SDK v2 Components

I hope you find them useful.

Happy SDKinging 🙂

Links

22 thoughts on “Tutorial: Using Eclipse with NXP MCUXpresso SDK v2 and Processor Expert

  1. Hi Erich!
    Can you extend this tutorial with for example UART or I2C module?
    I’m getting error, “UART0_BASE_PTR” undeclared.
    Thank you.

    Like

  2. Erich, do you have any insider knowledge on when the new FRDM-K28F boards will be released?

    It will have 1MB RAM. (might coax me back to Freescale from a detour through STM32)

    Like

  3. Hi Erich,
    well done! as always you are on the top front of the wave!
    Are you confident to install PE in the new coming MCUXpresso IDE? And do you know if it will be possible to use in it the SDK 1.3 (important for maintenance)?
    Michael

    Like

    • Hi Michael,
      yes, I have managed to get PE installed into the MCUXpresso IDE over the weekend and started writing an article about this, but was not able to finish it yet. I have not used it with the SDK V1.3, I used it with the McuOnEclipse components and SDK v2, but I don’t see why it should not work with the SDK 1.3 too.

      Like

  4. Erich,
    Do you know if NXP intend to support PE in future versions of MCUXpresso, or is that route closed from now on?
    Martin

    Like

    • Hi Martin,
      Processor Expert is not included in MCUXpresso IDE, and is a not supported by NXP. I have it working for porting over legacy projects, but don’t expect this a long term solution.
      Erich

      Like

  5. Pingback: The Influence of Software and Tools on ARM Cortex-M Microcontroller Vendor Selection | MCU on Eclipse

  6. Hi Erich,

    I´ve been trying to add a BitIO_LDD component instead of using a “LED” component in a existing project of mine, but I´m getting some building errors that I was not able to solve. My question is: can I add PEx to a SDK project using native PEx components? And what about these non LDD beans (like BitIO, for example) that don´t have a init method, what should I do initialize them?

    I can send you my SDK project, if it is the case.

    Like

  7. Pingback: MCUXpresso IDE: Installing Processor Expert into Eclipse Neon | MCU on Eclipse

  8. I think many designers that switched to Freescale in the past few years specifically because of the PEx tools are feeling a bit abandoned by NXP. I for one am evaluating other solutions again. It is a shame that Freescale made the investment in UNIS just to shelve the product. UNIS had the noble goal of multi-vendor support, and made PEx components for other micros besides Freescale. Freescale saw this technology as a way to get a competitive advantage, and they were correct in that assumption. Now they have flushed that tech down the toilet, along with many of the customers whom they gained because of PEx. It’s unfortunate.

    Like

    • I join mstroven in the rant. PEx is a great tool and I don’t know why it was flushed down the toilet. I think that it is a very nice feature to have, it helps with productivity and modularity of components. I want to understand why NXP gets rid of such a great tool.

      Like

      • Disclaimer: I don’t know the actual reasons, I only can speculate. I believe it is because PEx is not for everyone, so NXP would have to provide two different APIs/libraries: one for PEX and one for the SDK. Most developers are happy with a C/C++ library only. With only providing the SDK that would reduce the level of investment/maintenance. One way would have to be for PEx to create the drivers for the SDK. But the SDK API has changed a lot in the past. There were many changes in in SDK V1.0, V1.1, V1.2 and V1.3, and even more with the SDK v2.0. I saw that PEx tried to catch up with the changes of the SDK v1.x, so I think they gave up to do the step to v2. And there has been the tranformation from Freescale to NXP too.

        Liked by 1 person

  9. I knew and worked with the managers that worked on PE and now see their names in my linked-in list … attached to different companies. I think there were two reasons, cut costs by getting rid of a whole development team, and drop an product that never got complete traction within the corporation. PE never really integrated well with MQX and was entirely missing in other processor lines. I stopped using PE about three or four years ago because we spent endless hours trying to get a bsp in mqx that would integrate with PE, and it never happened. I never wanted to drop PE but we had to move forward.

    Now I have come back to the fold again because FreeRTOS seems the best choice for us over MQX and because I have seen that Erich has made the PE path viable again. Working with just the Kinetis sdk is extremely non-productive and prone to immense errors. For example they took the clock generation code that was originally from PE and less than 100 lines (it was used in mqx, as well as the first sdk’s) and in sdk v2.2 turned it into almost 2000 lines of code, not counting the number lines in the header file code, and it is unexplained wrt why and how anything works. They used a state machine to transition the clocks sequencing and everything is structures of structures and call backs. And it doesn’t work… for the PEE mode. The hello world project will lock on a tower board right out of the box. Compare that to setting a visual set of fields in PE and it works every time. I spent several days correcting that mess in SDKv2.2.

    If the PE components can work with the SDK v2.2, there is a way forward that is supportable for the long term.

    Extremely good work Erich, you have done was a corporation failed to do. Thank you.

    Like

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.