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 :-)

About these ads

8 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

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s