Sneaking from Processor Expert

Processor Expert is great: it generates initialization code and driver sources for me. This makes it a great knowledge and source base for non-Processor Expert projects too. Wondering how to initialize the SCI? What are again the register settings to use the CPU with a 6 MHz clock rate using an external crystal in low power mode? Lets generate a Processor Expert project to find out. Then copy-past the drivers or parts of it into my non-Processor Expert project. But How to do this?

I present here two different things: sneaking just a driver or a part of it, or sneaking the Processor Expert project as a whole. The first thing is more complicated and requires knowledge about the different parts of the generated code.

Sneaking a driver

If I have set up a Processor Expert component, it typically creates the files <baseName>.c and <baseName>.h:

Generated Files from Base Name

Generated Files from Base Name

I say ‘typically’, as a component can create more than just the header file and the implementation file, see the FreeRTOS component as example.

So I can simply copy the implementation file and the header file to my non-Processor Expert project. Very likely the implementation file will include as well other file like Cpu.h, which includes PE_Types.h, PE_Error.h, PE_Const.h and IO_Map.h. The easiest way is to copy these files too, but this might not ideal. The hard way is to analyze the implementation module and just add what I need.

What is missing is the initialization code. There are two pieces Processor Expert is using:

  1. CPU initialization code
  2. Driver Initialization code

The CPU initialization code is called from the startup code, and resides in CPU.c:

void __initialize_hardware(void)
{

  /*** !!! Here you can place your own code using property "User code before PE initialization" on the build options tab of the CPU component. !!! ***/

  /* ### MCF51JM128_80 "Cpu" init code ... */
  /*  PE initialization code after reset */
  /* Common initialization of the write once registers */
  /* SOPT1: COPT=0,STOPE=0,WAITE=1,??=0,??=0,??=0,??=0 */
  setReg8(SOPT1, 0x10U);                
  /* SOPT2: COPCLKS=0,COPW=0,USB_BIGEND=1,CLKOUT_EN=0,CMT_CLK_SEL=0,SPI1FE=1,SPI2FE=1,ACIC=0 */
...
}

This typically sets up the CPU clock: so if I’m interested in this part, this is what I was looking for.

The driver initialization code is called from main() and resides in PE_low_level_init():

void main(void) {  
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

At the beginning, it initializes the common port registers. This part is tricky, as it is not obvious what belongs to my driver I want to sneak out. The driver code initialization call (if any) is easy to spot:

AS1 Init Code

Processor Expert Driver Init Code

Next thing are the events (if there are any):

Processor Expert Component Events

Processor Expert Component Events

Processor Expert adds them by default into Events.c and Events.h. I usually double-click the green event method in above picture and it will jump to the piece of code. I simply could copy that code and past it into my non-Processor Expert project.

Last but not least: if the component driver is using interrupts, I need to add them to my vector table too. By default the Processor Expert vector table resides in Generated_Code\Vectors.c:

Interrupts Generated for Processor Expert Component

Interrupts Generated for Processor Expert Component

So I simply need to add the driver vectors to my vector setup.

With this, everything should work now.

Sneaking the project

If I’m not interested in a driver, but want to transform the Processor Expert project into a non-Processor Expert one, this is very easy. Because it might be easier to pass a complex project that way to somebody who does not like or know Processor Expert. Or because my licensing configuration includes all the advanced components, but not the person who needs the project.

I just need to remove the Processor Expert related project files. Dissection of MCU10 Projects gives the background about the files and folders in my project. From the root of my project, I remove the following files:

  • .ProcessorExpert.g_c
  • .ProcessorExpert.g_x
  • ProcessorExpert.pe

This removes all the Processor Expert related project information, and I have now a non-Processor Expert project.

Happy Sneaking 🙂

Advertisements

3 thoughts on “Sneaking from Processor Expert

  1. Pingback: Removal of Processor Expert for a Project | MCU on Eclipse

  2. Pingback: Generating Static FreeRTOS Source Code | 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 )

Google+ photo

You are commenting using your Google+ 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

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