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
.
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!
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:
I can create as many configurations I want, but only one is active at a time:
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:
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





Erich, thanks for sharing, but how can I get “FSL_USB_Stack” component?
Hi Jack! I plan to publish it on http://www.steinerberg.com/EmbeddedComponents/ as the other components. I have it working reliably on ColdFire V2. I run it as well on the S08 JM60, but there were some buffering problems I still need to investigate. I have it as well for MCF51JM128, but still need to test it a little bit. It is night and week-end work. But I plan to have it ready over the week end.
Happy reading your blog and expect the next one:)
Thanks, worked on it last night already. I already have a beta tester who contacted me directly signed up. On my end I have it now running as well on the DEMOJM board with the MCF51JM128 on it. Looks good
Hi Jack, I have posted more details on the “FSL_USB_Stack” component in http://mcuoneclipse.wordpress.com/2012/03/10/usb-or-not-cdc-with-processor-expert/. The component is now published on http://www.steinerberg.com/EmbeddedComponents/FSL_USB_Stack and examples are on http://www.steinerberg.com/EmbeddedComponents/Examples/Example_PE_CDC_V1JM128.
Pingback: USB or not: CDC with Processor Expert | MCU on Eclipse
Pingback: Changing the CPU with Processor Expert | MCU on Eclipse
Pingback: Switching Processor Package in Processor Expert | MCU on Eclipse