Getting Started with CodeWarrior IDE from Freescale
CodeWarrior Development Studio is a complete Integrated Development Environment (IDE) that provides a highly visual and automated framework to accelerate the development of complex embedded applications using Freescale processors. One of the best features of this environment is its support across the most used platforms available to developers: Windows, Linux, Mac, Solaris. Also special versions exist for specialised operating systems destined for PlayStation 2, Nintendo, Wii. Palm OS and Symbian OS can also run CodeWarrior to some extent. The IDE is centred on C and C++ compilers and includes all the tools necessary to complete an embedded (software) project: text editors, compilers, simulators, debuggers etc.
Due to the huge complexity of a single tool that would support the broad range of Freescale products, special and smaller versions of CodeWarrior are available being specialised in dealing with particular families and architectures. This also allows for cost savings, taking into account that if you plan to use the CodeWarrior for developing on ColdFire architectures, you would hardly need any StarCore DSP functionality. Thus, various versions of the environment are available for purchasing and download supporting:
-
-56800/E Digital Signal Controllers
-68k Embedded Systems
-ColdFire architectures
-HCS12(X) microcontrollers
-RS08/HC microcontrollers
-mobileGT applications
-MPC55XX processor family
-Power Architecture Netcomm Processors
-StarCore DSP
Short history
CodeWarrior was initially developed by a company called Metrowerks (Canadian) and was initially targeting the PowerPC of the Macintosh. However, after the 1999 acquisition of Metrowerks by Motorola (the big fish eats the little fish) the scope of CodeWarrior was changed to embedded systems; after 2005 support for Mac processors was discontinued completely. Nowadays the IDE belongs to Freescale and supports all the above mentioned targets.
On a more mundane note, the name of CodeWarrior was inspired by the Mad Max film series (Mad Max 2: The Road Warrior)
Get started
The company I work for has recently started using HCS12 micros so we had to purchase the CodeWarrior version dealing with them. Using a new programming environment might not have been so difficult for our software developers (they have probably seen tens of them so far), but it was for me (I am a hardware engineer myself). Normally I should not have dealt with writing any code at all, but due to the strain put on all the people in the company (or on the “resources”, as the managers put it) I had to write small pieces of code just to test various sections of the hardware we are designing.
When I was first told we are using CodeWarrior I just told myself it must be for Freescale just what MPLAB is for Microchip, or what AVR Studio is for Atmel (I am more familiar with these). And I was not far from the truth (of course professional software developers might argue against this).
I tried to structure the initial experience with this powerful development environment in a few easy to follow steps.
Step 1 – download and installation
CodeWarrior costs money. It does not come cheap. Fortunately, Freescale makes available free versions which only allow limited code sizes to be built. These versions are more than enough to get a heads-up on how it looks and works.
Visit Freescale in order to download any of the available packages. Because this was what I needed, I have downloaded the special version of the HCS12X Microcontroller family and this is what I will refer to below. Once you have downloaded it, the installation procedure is the familiar Windows style “Next”-> “Next”->”Finish”-“Launch” process.
Alternatively, Freescale also allows the download of fully functional versions of CodeWarrior, but only for a 30-day evaluation period.
Step 2 – Creating the project
After you launch CodeWarrior, from the top menu bar choose File->New, which will pop up the “New” widow which allows you to start a wizard. Select the Wizard option and enter a name for your project (in this case, I selected the name “Tutorial”:

Go through the wizard, selecting the MC9S12E128 as the derivation that you want to compile for and C as the set of languages to work with:

The project wizard has quite a few pages. Go through all of them selecting successively: no Processor Expert, no set up for PC-lint, ANSI startup code, no supported floating point format, banked memory model. On the last page, the wizard lets you select a debugger/programmer or a simulator. For now, just select the simulator, as you will always be able to switch to a physical device once the project has started. And I do like to simulate my code:

Step 3 – Writing the code
Following the successful completion of the last step in the wizard, CodeWarrior will display a Project window docked on the left side of the environment. To get to the actual files where you write the code, you will have to click on the small “+” sign near the “Sources” folder, which will reveal the existing files in your code. For now, there are only two, and you will want to edit the main.c file, by double clicking on it.
The code automatically generated is kept to a minimum and should not be too overhelming even for a beginner:
#include
#include
void main(void) {
/* put your own code here */
EnableInterrupts;
for(;;) {} /* wait forever */
/* please make sure that you never leave this function */
}
To turn pin PB7 high you only need to write two registers: PORTB and DDRB. Fortunately, all registers are defined in the mc9s12e128.h file which is included in the beginning of the code, so I did not even have to search the datasheet for the register addresses. The DDRB register is the direction register for PORTB pins. When port B is operating as a general-purpose I/O port,
DDRB determines the primary direction for each port B pin. Logic 1 cause the associated port pin to be an output and a 0 causes the associated pin to be a high-impedance input. The value in a DDR bit also affects the source of data for reads of the corresponding PORTB register. If the DDR bit is 0 (input) the buffered pin input state is read. If the DDR bit is 1 (output) the associated port data register bit state is read. To make things simple, I just wrote the DDRB register with FF (all pins are output) and then I set the PB7 pin high with a single write to the PORTB register. My code looked like this:
#include
#include
void main(void) {
/* put your own code here */
EnableInterrupts;
DDRB=0xFF;
PORTB=0x80;
for(;;) {} /* wait forever */
/* please make sure that you never leave this function */
}
Step 4 – Simulating the code
Before you initialise the simulation you might want to have a look at all the simulation settings that can be made. The corresponding window may be invoked by ALT+F7 or you may launch it with the menu Edit->Full Chip simulation Settings. Just by seeing the many tweaks and settings you can make here, you can get a pretty good idea of how powerful and useful the simulator (and hence the environment) may be:

A neat feature of CodeWarrior is that it allows you to have a visual representation of the pin states, through a component called IO_LED. To activate the component, in the simulation window, chose from the menu Component->Open. This will display a broad array of “components” to choose from, the component being basically a graphic way of displaying information. From all the options available, please choose the “io_led” one:

More information and download under: CodeWarrior Development Tools
Read the Italian version: Iniziare con CodeWarrior IDE della Freescale
CONTACT REQUEST
If you want to know more about this Freescale product, please submit your request to Arrow Italy using this form.
NOTE: this form is valid ONLY for Companies or Customers based in Italy and working in the Italian area.
- brumbarchris's blog
- 2048 reads





Post new comment