Building the example code
4. Go to the include folder that was downloaded from the web site http://www.freescale.com/etpu (see
Generating the eTPU code
). Select the etpu_struc.h and mpc5674f_vars.h files, and select Copy through right-click. Then go to the
CW project, select Project_Headers, right-click it and select Paste; the typedefs.h file was already included when the project was created.
5. Select the etpu folder that was downloaded from the web site http://www.freescale.com/etpu (see
Generating the eTPU code
), and select Copy through right-click. Then go to the CW project, select Sources, right-click it and select Paste.
6. Add directories where etpu header files can be found. Choose Project > Properties > C/C++ Build > Settings >
PowerPC Compiler > Input, and add all next locations of the etpu folder:
• "${workspace_loc:/${ProjName}/Sources/etpu}"
• "${workspace_loc:/${ProjName}/Sources/etpu/_utils}"
• "${workspace_loc:/${ProjName}/Sources/etpu/pwm}"
• "${workspace_loc:/${ProjName}/Sources/etpu/_etpu_set/cpu}"
For example, for the first one: Click the 'Add...' icon and then choose Workspace-> <project name> > Sources >
etpu > OK. See Figure 1 .
Figure 1. Include directories
5 Building the example code
This section describes the procedure to build the example code. There are two options:
• Reusing the examples code from the eTPU Application notes. See References .
• Using the eTPU Graphical Configuration Tool.
The first option is recommended for eTPU beginner users and the second option helps to build a particular application using the APIs.
This section uses the example code available from the application note, AN2849: Using the eTPU Pulse Width Modulation
(PWM) Function, on http://www.freescale.com
.
• Go to http://www.freescale.com
then, on search section, look for AN2849 and on the results, the link
AN2849SW_PWM, appears along with the application note. Click the link and follow the instructions to download, unzip it and the files for two example codes can be seen.
File
pwm_example1.c
Table 2. AN2849 files
Description
Rev : 2.3 - Example C code file for MPC5500 products.
Table continues on the next page...
eTPU Libraries Integration to CodeWarrior (CW) 10.x, Rev. 0, 8/2012
Freescale Semiconductor, Inc.
5
Building the example code
Table 2. AN2849 files (continued)
File
pwm_example1.h
pwm_example2.c
pwm_example2.h
Description
Rev : 2.2 - Example header file for MPC5500 products.
Rev : 2.3 - More complex example C code file for MPC5500 products.
Rev : 2.2 - More complex example header file for MPC5500 products.
The etpu_pwm.c and etpu_pwm.h files are already included in the etpu/pwm folder that were downloaded from http:// www.freescale.com/etpu
. (See Generating the eTPU code )
For the first example in
Table 2 , copy the pwm_example1.h file and paste it on the Project_Headers folder of the CW10.x
project.
The code for the main.c file of the CW10.x, will be taken from the pwm_example1.c file, so open it, select all the text, copy and replace it on the main.c file.
The pwm_example1.c file is using the GPIO drivers from the application note, AN2855: Pad Configuration and GPIO Driver for MPC5500, available on http://www.freescale.com
.
• Go to http://www.freescale.com
, then, on search section, look for the AN2855 and on the results, the link AN2855SW,
appears. Click this link and follow the instructions to download, unzip it and the files listed in Table 3 will be seen.
File
fs_gpio.h
siu_struct.h
fs_gpio.c
Table 3. GPIO files
Description
Contains definitions of various macros and functions used by the fs_gpio API
Contains a structure definition for the SIU which is used by the API.
Contains C code for the fs_gpio API
Copy the fs_gpio.h and siu_struct.h files and paste in the Project_Headers folder of the CW10.x project.
Do the same for the fs_gpio.c file, copy and paste in the Sources folder of the CW10.x project.
Now, on the main.c file, some lines need to be updated to migrate from MPC5554 to PXR4040. See Table 4 .
1. Update the headers files.
Table 4. Headers to update for
PXR4040
Header file
#include "..\mpc5500\mpc5554.h"
#include "..\utils\etpu_util.h"
#include "..\mpc5500\fs_gpio.h"
#include "..\etpu_set1\etpu_set1.h"
#include "mpc5554_vars.h"
Updated header files for PXR4040
#include "PXR4040.h"
#include "etpu_util.h"
#include "fs_gpio.h"
#include "_etpu_set\etpu_set.h"
#include "mpc5674f_vars.h"
2. Update the system clock, so delete the line
FMPLL.SYNCR.R = 0x06000000; /* System Frequency set to 128 MHz */
6
eTPU Libraries Integration to CodeWarrior (CW) 10.x, Rev. 0, 8/2012
Freescale Semiconductor, Inc.