I have an example project with Processor Expert and CodeWarrior. The problem I have is that I want to use it for another CPU derivative. So how can I migrate the project?
There are three different approaches:
- Change Wizard: In MCU10.2 there is the menu Project > Change Device/Connection. While this sounds promising, it only works for the very simple projects. And it does not change the project in-place: it simply creates a copy of the project and applies some (many times wrong) settings. So I do not recommend to use that option.
- New Project Wizard: For me in most cases this is the best way: this creates a new project for the new device, with everything set up correctly. In a second step I copy my source files and compiler settings (if I have changed them). The Processor Expert component I can transfer with using drag&drop.
- Changing the CPU: With Processor Expert, I can change the CPU. For this I add a new CPU to the project and change other settings (debugger, build tools settings) as needed.
- Approach 1) is something I stopped using, because it does not work for me.
- Approach 2) is something I do when need to do larger changes or migrations. Then it is easier to do it in little steps and change one thing after each other.
- Approach 3) is the preferred way if I do rather minor changes, e.g. changing the derivative. And this approach works best in combination with approach 2) as I have an example project to look at.
That makes in reality only two. I focus here on approach 3) as this gives a good insight behind everything.
From MCF51JM128 to MCF51JM64
But similar steps can be applied for any other Processor Expert projects. And I’m changing the project from using the 128 KByte Flash version to the smaller MCF51JM64.
Make a Backup!
As I’m going to make the changes in-place and therefore might ‘destroy’ my original project, I create a backup of it.
Adding the CPU
As a first step I’m adding the new CPU which I want to use. In the Components Library all supported CPU’s are listed in a tab:
Double clicking on the item or using the ‘add’ (+) button shows this dialog where I can select my pin variant I want to use:
Pressing Finish and it will add it to my list of CPU’s in the project:
Actually it has added a new configuration too. See configurations with Processor Expert. I could keep both configurations, and then later switch between the two derivatives. But to keep things simple, I’m removing the old configuration:
Similarly I could remove the old CPU as well. The only thing I need to think about is: are there any specific settings I have made in the previous CPU? If so, I need to apply it to the new CPU, and it is easier to do this while the old CPU is still there, so I can simply click on it an inspect the settings. In my particular example I had configured the clock settings to use a 24 MHz external crystal. And I had disabled generation of the linker file with a special entry in the LCF (Linker Configuration File), plus enabled Delay100US(). See USB or Not: CDC with Processor Expert. I need to apply the same changes for the new CPU. Then I remove the CPU:
Now it is very possible that the components I have in my project needs to know about the new CPU too. For example timer peripherals are different, or pin names have changed. It is best practice to go through all the components and make changes as needed. For the USB CDC project I need to change the CPU for the USB stack driver from JM128 to JM64:
Build Tool Settings
This step heavily depends on the change, and requires in dept knowledge about the compiler and build tool settings. As for the component settings, my choice of the CPU might have an impact on the build tool settings. I might change the libraries or compiler options. In my example here I do not need to change anything, as the compiler settings are the same.
Tip: If I’m not sure about the settings, I simply create an example project with the wizard (menu File > New > Bareboard Project) with Processor Expert and inspect the settings.
Now I do a clean (menu Project > Clean), generate Processor Expert code (menu Project > Generate Processor Expert Code) and build it (menu Project > Build Project). This should just go fine.
Next thing is the check and change the debug and launch configuration. It is possible to create a brand new connection (see Flashing with a button), but here I’m simply patching my existing configuration to run with the JM64. Unfortunately this is 3 levels deep in the dialogs. I open the Debug Configuration with the menu Run > Debug Configurations:
The old CPU name JM128 is still used here in many places for names, but this does not bother me now. What is more important is to tell the debugger that it needs to connect and download to a JM64. For this I click on the ‘Edit…’ button for the Connection in above dialog and get:
Here I press “Edit…” on the Target and get finally to the important stuff:
Here I change the target type to my new derivative. And the same time I can change the name as well (although more cosmetic):
What remains is the initialization script and memory configuration file. And here it is best to simply copy them from an example project from the approach 2) from the beginning:
Now it is time to download and debug the project.
Tip: If for whatever reason it is not working, then probably I missed a setting. For this it is always good to go first with the simple project from approach 2) and compare with this one.
As noted in the debugger configuration dialog, the old CPU name is still used in several places. If I don’t mind, then I’ll keep it as it is. Changing names in the Launch Configuration dialogs is simple.
If I want to change things, then here it is:
One thing is the name of the folder where all the object and make files are generated:
The Build Directory name/path is configured here:
The name of the application file is configured here:
The name of the build configuration can be changed here:
The Project Name can be changed with a context menu:
The changed project name, output file name needs to be reflected in the launch configuration:
With this, I have successfully transformed my MCF51JM128 project to use the MCF51JM64 instead:
Changing the CPU for a project is not that hard. Yes, it requires to know what I am doing, and requires multiple steps in different places. But going through that exercise helps me to better understand how things are linked together and working :razz:.