Configurations with Processor Expert

I have to make an application configuration decision: Using USB CDC or RS-232?

In the lab I use a Tower system which offers both RS-232 and USB connectivity. It uses a FSShell component to communicate with a terminal on the host. Typically this is using an RS-232 serial cable connected to the host. Well, the challenge is that today most notebooks do not have a serial port any more. But they have USB.

So I ended up implementing both serial/RS-232 and USB CDC (Communication Device Class) support. Everything with Processor Expert components :-).

Selection between USB and Serial in the FSShell

Selection between USB and Serial in the FSShell

Processor Expert in CodeWarrior for MCU10.2 is great in configuring the hardware and generating drivers. But in my case I need to switch between different operation modes of my hardware: either I use RS-232 or I use USB CDC. And this means different components and different settings :-(.

On the software side I use #defines in my platform header file to configure the system:

#define PL_HAS_SHELL        (1)
  /*!< if we have shell support */
#define PL_USE_USB_SCI      (0 && PL_HAS_SHELL && PL_IS_TOWER_BOARD)
  /*!< if we route SCI through USB (CDC) */

So if I want to switch to USB CDC in my application, I turn that PL_USE_USB_SCI macro to 1. That works fine, except that way I cannot switch configurations in Processor Expert.

But wait, there are configurations in Processor Expert!

Configuration Folder in Processor Expert

Configurations Folder in Processor Expert

If I create a Processor Expert project in MCU10, it already comes with a default configuration. I can rename it or add configurations using the context menu. That way I can create two configurations: one for USB and one for RS232:

USB and RS232 Configuration

USB and RS232 Configuration

I can create as many configurations I want, but only one is active at a time:

Selecting the Active Configuration

Selecting the Active Configuration

To add/remove components to a configuration, I simply enable or disable the component. If required I can have the same component multiple times in the project with different settings depending on the configuration selected:

Configurations Side-by-Side

Configurations Side-by-Side

Now I can switch between two configurations just with a mouse click. But what about my define for PL_USE_USB_SCI? Luckily there is a solution for this too :-).

The cool feature is that Processor Expert generates for each configuration a define. It is defined in the header file for the CPU component (usually Cpu.h). So depending on which configuration is active, it creates

/* Active configuration define symbol */
#define PEcfg_USB                   1U

or

/* Active configuration define symbol */
#define PEcfg_RS232                 1U

The define starts with PEcfg_ and uses the name used in the configuration. This allows me to rewrite my macros using PEcfg_USB:

#define PL_USE_USB_SCI      (defined(PEcfg_USB) && PL_HAS_SHELL && PL_IS_TOWER_BOARD)
  /*!< if we route SCI through USB (CDC) */

Changing Processor Expert configuration has now a direct impact on the components and automatically configures the user software part of my application. Neat!

Happy Configuring 🙂

16 thoughts on “Configurations with Processor Expert

  1. Pingback: USB or not: CDC with Processor Expert | MCU on Eclipse

  2. Pingback: Changing the CPU with Processor Expert | MCU on Eclipse

  3. Pingback: Switching Processor Package in Processor Expert | MCU on Eclipse

    • Hello,
      Processor Expert is free in the sense of ‘free of charge’. So it is not limited (except that it is limited for Freescale devices). But it is not ‘open source’, means Freescale provides it free of charge, but you it not ‘free open source’ e.g. like GNU.

      Like

  4. Pingback: RAM Target with Kinetis Design Studio and FRDM-K64F | MCU on Eclipse

  5. A very useful feature (which is implicit in the screen shots but not emphasised in the text) is the ability to have two components with the same name (e.g. LED_Red, or AS1) but different settings (e.g. pin assignment and active high or low) then enable one in each configuration. Then the code remains identical between configurations – no need even to use the #define (in this case).

    I suppose you can even switch between different processors (e.g.KL25 or KL05) – though I have not tried that yet.

    Like

    • Yes, sorry that I did not mention that, as I use components with the same name all the time that way, it was to logical for me :-(. And yes, you can use two different processors like that too. But I recommend that only if it does not require compiler/project setting changes (e.g. I would not switch between a Kinetis-K and a Kinetis-L that way). But doable for switching between different memory sizes (e.g. KL25Z32 vs KL25Z128 or inside the same family).

      Like

  6. Pingback: Switching the Microcontroller Package, Device and Family | MCU on Eclipse

  7. Is there a way to specify a PE Configuration to be used with a specific Build Configuration?

    I.e. I would like to just choose a Build Configuration and that will in turn select the appropriate PE configuration.

    CW for MCU 10.7.

    Like

    • Hi Paul,
      unfortuntately, this is not supported. The CDT build configurations are not linked to the Processor Expert configurations. That’s I wish/feature request I have for a long time too.
      Erich

      Like

What do you think?

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