Home

eTPU Libraries Integration to CodeWarrior (CW) 10.x

image

Contents

1. Freescale Semiconductor Document Number AN4572 Application Note Rev 0 8 2012 eTPU Libraries Integration to CodeWarrior CW 10 x by Antonio Pintor Automotive and Industrial Solutions Group Contents 1 Introduction Eo tgs LEY o 1 The purpose of this application note is to help the users to 2 ru matoa Diy ae pani integrate the Enhanced Time Processing Unit eTPU libraries interlace AP Dheoise 2 published on the Freescale website into a stationary based 3 Generating Tie STP aide eranacnninnna 3 CodeWarrior 10 x CW10 x project for PX family of devices F a pulse width modulation PWM example will be used to 4 Integrating the etpu files to CW10 X eee 4 describe this integration This procedure can be used on any S Building theexample de iicicccsaicccissiunmcninds 5 device that includes an eTPU module f j i 6 Using the eTPU Graphical Configuration Sample code written for the PXR40 device can be downloaded WON ERAEN N EENE E A AE EEE 7 from AN4572SW available at http www freescale com EATE T a PE E E A E E 11 This application note must be read with application note iusi AN2849 Using the eTPU Pulse Width Modulation PWM SS AMEN SIEM E E E E E Function available at http www freescale com w Tee naa AR 13 The eTPU is a programmable I O controller with its own core and memory system allowing it to perform complex timing and I O management independently of the CPU The eTPU is essentially an independent mic
2. my system_etpu_init my system_etpu_start Init the eTPU engine and eTPU channels Start eTPU and eMIOS timers Loop forever for i Compile and run the project connect the oscilloscope to ETPU_A Channel 0 and the user will see the PWM signal running at 2 kHz and 50 of duty 7 Summary A set of eTPU functions configured to cooperate together is called eTPU application An eTPU application API capsulizes several eTPU function APIs The eTPU application API includes CPU methods which show how to initialize control and monitor an eTPU application and to easily use the eTPU as a coprocessor Figure 5 shows an example of the eTPU project structure for motor control eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc 11 Summary Software Level Source Code Files User Application Initialization Methods my_system_etpu_ init my system_etpu_ start User eTPU Initialization etpu util c h Code Generated by eTPU etpuc h etpuc_common h CPU Code Freescale supplied code eTPU Code an supplied c ByteCraft supplied code Figure 5 eTPU project structure 7 1 Sample CPU initialization The following code lines show a typical example of the CPU and eTPU initialization main PXR40_init mySystem_init Initialize sysclk frequency etc eTPU Libraries Integration to CodeWarrior CW 10
3. AN2853SW_UART Receiver Transmitter UART eTPU Function AN3379 Using the CEA709 eTPU Function AN3379SW_CEA709_SET 9 4 eTPU function library and API Automotive eTPU functions AN3768 eTPU Automotive Function Set Set 2 AN3768SW AN3769 Using the Engine Position CRANK and AN3769SW CAM eTPU Functions AN3770 Using the Fuel eTPU Function AN3770SW AN3771 Using the Spark eTPU Function AN3771SW_SPARK AN3772 Using the Knock Window eTPU Function AN3772SW_KNOCKWINDOW eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc References 9 5 eTPU function library and API Motor control eTPU functions eTPU Function AN2958 Using the DC Motor Control eTPU AN2958SW_DCMOTORSET Function Set set3 AN2968 Using the AC Motor Control eTPU AN2968SW Function Set set4 AN2840 Using the DC Motor Control PWM eTPU AN2840SW Functions AN2841 Using the Hall Decoder HD eTPU AN2841SW_HD Function AN2842 Using the Quadrature Decoder QD AN2842SW_QD eTPU Function AN2843 Using the Speed Controller SC eTPU AN2843SW_SC Function AN2844 Using the Current Controller CC eTPU AN2844SW_CC Function AN2845 Using the Break Controller BC eTPU AN2845SW_BC Function AN2846 Using the Analog Sensing for DC Motors AN2846_ASDC ASDC eTPU Function AN2869 Using the Stepper Motor SM eTPU AN2869SW_SM Function AN2969 Using the AC Motor Co
4. Loop driven by eTPU on MPC5554 AN3005SW AN3006 BLDC Motor with Hall Sensors and Speed Closed Loop driven by eTPU on MPC5554 AN3006SW AN3007 BLDC Motor with Speed Closed Loop and DC Bus Break Controller driven by eTPU on MPC5554 AN3007SW AN3008 DC Motor with Speed and Current Closed Loops Driven by eTPU on MPC5554 AN3008SW AN3205 AC Induction Motor Volts per Hertz Control with Speed Closed Loop Driven by eTPU on MPC5500 AN3205SW AN3206 Permanent Magnet Synchronous Motor Vector Control Driven by eTPU on MPC5500 AN3206SW AN3769 Using the Engine Position eTPU AN3769SW Functions eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc How to Reach Us Home Page www freescale com Web Support http www freescale com support USA Europe or Locations Not Listed Freescale Semiconductor Technical Information Center EL516 2100 East Elliot Road Tempe Arizona 85284 1 800 521 6274 or 1 480 768 2130 www freescale com support Europe Middle East and Africa Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen Germany 44 1296 380 456 English 46 8 52200080 English 49 89 92103 559 German 33 1 69 35 48 48 French www freescale com support Japan Freescale Semiconductor Japan Ltd Headquarters ARCO Tower 15F 1 8 1 Shimo Meguro
5. etpu files This procedure is specific to PXR40 but the steps may apply to any device that includes an eTPU module 1 Open the CW10 x 2 Choose File gt New gt Bareboard Project to create New Project and write the project name 3 Choose PX gt PXR Family gt PXR4040 to select the device and follow the instructions to create the new project eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 4 Freescale Semiconductor Inc _ 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 gt Properties gt C C Build gt Settings gt PowerPC Compiler gt 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 work
6. Meguro ku Tokyo 153 0064 Japan 0120 191014 or 81 3 5437 9125 support japan freescale com Asia Pacific Freescale Semiconductor China Ltd Exchange Building 23F No 118 Jianguo Road Chaoyang District Beijing 100022 China 86 10 5879 8000 support asia freescale com Document Number AN4572 Rev 0 8 2012 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductors products There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document Freescale Semiconductor reserves the right to make changes without further notice to any products herein Freescale Semiconductor makes no warranty representation or guarantee regarding the suitability of its products for any particular purpose nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit and specifically disclaims any liability including without limitation consequential or incidental damages Typical parameters that may be provided in Freescale Semiconductor data sheets and or specifications can and do vary in different applications and actual performance may vary over time All operating parameters including Typicals must be validated for each customer application by customer s technical experts Freescale Semiconductor does not convey
7. _ Figure 4 Configuring the Engine A channels e Save the eTPU configuration as pwm_etpu_gct c in a known folder Go to this folder and there will be two files pwm_etpu_gct c and pwm_etpu_gct h e Copy the first one pwm_etpu_gct c and paste in the Sources folder of the CW10 x project e Copy the other file pwm_etpu_gct h and paste in the Project Headers folder of the CW10 x project 6 3 main c file The main c file contains the main routine This routine initializes the PXR40 device for 256 MHz CPU operation and calls the functions to initialize the eTPU according to the information in the my_etpu_config struct stored in pwm_etpu_gct c file The time bases are enabled by calling routine fs_timer_start This example uses the pin ETPUAO include PXR4040 h include pwm_etpu_gct h void initSysclk_at_256 MHz void FMPLL ESYNCR2 R 0x00000003 Change clk to PLL normal mode from crystal initially 128 MHz with 40 MHz crystal eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 10 Freescale Semiconductor Inc C Summary FMPLL ESYNCR1 R 0xF0040030 EPREDIV 4 EMFD 48 CLKCFG 7 while FMPLL SYNSR B LOCK 1 Wait for FMPLL to LOCK FMPLL ESYNCR2 R 0x00000001 Change divider final value for 256 MHz sysclk int main void volatile int i 0 initSysclk at_256 MHz Init system clock at 256 MHz SIU PCR 114 R 0x0600 Enable ETPU_A Channel 0 as output
8. adjusted to the actual eTPU features of the selected processor e Offers a well ordered table of channels and assigned eTPU functions e No eTPU feature is hidden All configurable items are available e Primarily determined for Freescale provided eTPU function sets but can be used with any user sets supplied in a proper format e Automatic extraction of configuration information from eTPU function interface routines API e Automatic generation and reading of a C file containing my_system_etpu_init and my_system_etpu_start functions The functions configure the eTPU using standard Freescale eTPU utilities and eTPU functions API For detailed information go to Help gt User Manual of the eTPU Graphical Configuration Tool which can be downloaded from http www freescale com etpu 6 2 Creating code to initialize and configure the etpu This section describes how to use the eTPU GCT to generate code for the initialization and configuration of the eTPU PWM example 1 Create a new project and repeat the steps given in Integrating the etpu files to CW10 x 2 Choose Start gt All programs gt Freescale gt eTPU Graphical Configuration Tool gt eTPU Graphical Configuration Tool to open the eTPU GCT 3 Choose eTPU gt Options gt Function Sets gt lt Path of the etpu libraries folder gt gt OK to set the path where eTPU libraries were downloaded according to Generating the eTPU code See Figure 2 eTPU Libraries Integration to Co
9. annels Verbatim Block Engine Disabled flow power mode clocks stopped m TCR1 Clock TCR1 STAC Bus Operation Clock Source ERE ck dh 64MHz I Enable TCR1 STAC Bus operation Prescaler fi TCR1 Frequency 64 MHz oe sits ee TE m TCR2 Clock TCR2 STAC Bus Operation Clock Source Gated eTPUCLK 8 gated by TCRCL v f6 MHz Enable TCR2 STAC Bus operation Prescaler 1 TCR2 Frequency 16MH i a tesc f y 2 C ENE AN To Angle Mode Angle mode disabled v In ngle Mode a special hardware is enabled that works in combination with r Scheduler Priority passing the TCRCLK signal TCR2 counter and microcode processing to generate TA a angle information on the TCR2 bus T Disable priority passing m Channel Input Digital Filter M TCRCLK Digital Filter Channel input signals are filtered by a digital filter TCRCLK signal controls TCR1 and TCR2 clocks in for improved noise immunity externally clocked modes The signal is filtered by a digital filter for improved noise immunity Digital filter sample rate eTPUCLK 2 S 64 MHz Digital fiter mode Digital filter mode Two Sample Mode eTPU clock divided by 64 MHz Digital filter is guaranteed to Same as channelinput fiter 64 MHz Detect pulses from width 31 25 ns Digital filter sample rate Filter pulses up to width 15 625 ns 5 k 3 S Watchdog 1 r Channel Timing Mode Mode Disabled v Count fo lo ms Normal Figure 3 Configuring the En
10. any license under its patent rights nor the rights of others Freescale Semiconductor products are not designed intended or authorized for use as components in systems intended for surgical implant into the body or other applications intended to support or sustain life or for any other application in which failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application Buyer shall indemnify Freescale Semiconductor and its officers employees subsidiaries affiliates and distributors harmless against all claims costs damages and expenses and reasonable attorney fees arising out of directly or indirectly any claim of personal injury or death associated with such unintended or unauthorized use even if such claims alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part RoHS compliant and or Pb free versions of Freescale products have the functionality and electrical characteristics as their non RoHS complaint and or non Pb free counterparts For further information see http www freescale com or contact your Freescale sales representative For information on Freescale s Environmental Products program go to http www freescale com epp Freescale and the Freescale logo are trademarks of Freescale Semiconductor Inc All other pr
11. deWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc 7 AX Using the eTPU Graphical Configuration Tool File Edit View eTPU Help Deut e Processor Function Set Engine A Engine A Channels Engine B Engine B Channels Verbatim Block r Search Directories Function Sets C eTPU_Libraies PWM etpu Help Reference Manual doc E TPURM pdt E App Notes doc appnotes E Note All paths can be specified either as absolute path or as a path relative to eTPU GCT application exe file Cancel Figure 2 Setting the path to eTPU Files 4 Close the eTPU Graphical Configuration Tool without saving and open it again this will update the link that will point to the path setting on step 3 5 Click the Processor tab and choose MPC5674F to select the target CPU Click Processor tab and choose System clock gt 128 MHz to set the Clock Settings to 128 MHz 6 Click the Function Set tab and choose etpu_set h to select the eTPU Function Set to be used 7 Configure the Engine A as depicted in Figure 3 e Select Engine A tab e Choose TCR1 gt Clock Source and select Internal eTPU clock divided by 2 e Set all other configuration by default eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 8 Freescale Semiconductor Inc Using the eTPU Graphical Configuration Tool Eile Edit View Help DEB tLe Processor Function Set Engine A Engine A Channels Engine B Engine B Ch
12. eTPU function abbreviation in lower case 3 1 2 etpu_pwm h This header file contains the function prototypes of the PWM API C source code contained in etpu_pwm c The standard names of eTPU function API files are etpu_ lt func gt c h where lt func gt is the eTPU function abbreviation in lower case 3 1 2 1 etpu_util h This header file contains the function prototypes to initialize and configure the behavior of the eTPU engine This header file also contains symbols used by the eTPU function API The C source code for configuring and loading the eTPU engine is contained in etpu_util c This header file and the source file are common to use for any etpu API function 3 1 2 2 etpu_set h This file contains the microcode of the eTPU functions that will be loaded into eTPU Code Memory Only the eTPU functions from this set will be available for assignment to eTPU channels The eTPU function set binary images are distributed as C header files etpu_setX h where X is the function set ID Each eTPU function set header file contains e the function set binary image e the global constants e Entry Table Base ETB address e Multiple Input Signature Calculator MISC compare value For detailed information see ETPURM Enhanced Time Processing Unit eTPU Reference Manual available on http www freescale com 4 Integrating the etpu files to CW10 x This section helps the users to create the CW10 x project for the PWM example and integrate the
13. egration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc O E Using the eTPU Graphical Configuration Tool None of the clocks setup for PXR40 will hold the default clock system equal to 60 MHz with 40 MHz Crystal 3 Change the following line in the eTPU Clock const uint32 t etpu_a_tcrl freq 64000000 64 MHz to const uint32 t etpu_a_tcrl freq 15000000 60 MHz 2 30 MHz eTPU clock 2 prescaler 15 MHz 4 Open the pwm_example1 h file and change the header include utils etpu_util h to include etpu_util h 5 Finally open the fs_gpio h file locate the definition of FS_GPIO_PRIMARY_FUNCTION and modify the value from 0x0C00 to 0x0400 This step is followed for compatibility with the PX family Now the program is ready to compile and run connect the oscilloscope to ETPU_A Channel 0 and the user can see the PWM signal running at 2 kHz and 60 of duty 6 Using the eTPU Graphical Configuration Tool 6 1 Introduction The eTPU Graphical Configuration Tool GCT is a Windows application created for Freescale eTPU users The GCT offers a user friendly graphical environment to configure the eTPU and generate initialization routines coded in C language Main features of the GCT are as follows e Graphical environment that guides a user through the configuration descriptions options checking conflicts e Supports various Freescale processors with the eTPU The graphical environment is
14. gine A 8 Configure the Engine A Channels as shown in Figure 4 e Click the Add Function button and the Add eTPU Function windows dialog box appears e Go to Parameter Values section and change the priority value to Middle e Set the freq value to 2000 kHz and set the duty value to 5000 it represents 50 Resolution 0 01 e Set all other values by default eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc 9 Using the eTPU Graphical Configuration Tool Add eTPU Function meesi eTPU Function PWM Cancel C API to be used fs etpu_pwm_init The eTPU function provides one or more C language API calls which define how many channels and what parameters are used by the eT PU function Channels Parameter Values V Show parameter tips Channel Name Parameter Name Value Type channel priority Middle uint8_t freq 2000 uint32_t duty 5000 uintl6_t polarity FS_ETPU_PWM_ACTIVEH uint8_t timebase TCR1 uint8_t timebase_freq Engine TCR1 frequency uint32_t Generated Code FA 7 eTPU API Function initialization PWM s7 err_code fs_etpu_pwm_init PWMx_ CHANNEL engine A channel 0 FS_ETPU_PRIORITY_MIDDLE priority Middle 2000 freq 2000 5000 duty 5000 FS_ETPU_PwWM_ACTIVEHIGH polarity FS_ETPU_PwWM_ACT FS_ETPU_TCR1 timebase TCR1 etpu_a_tcrl_freq timebase_freq Engine A TCR1 fre if err_code 0 lt m ee
15. n This design improves the flexibility of the eTPU functions implementation and the portability of the host application code 2 eTPU function library and application interface API The eTPU function APIs enable the use of eTPU functions in applications The eTPU function APIs include CPU methods that demonstrate how to initialize control and monitor the eTPU function The CPU application does not need to access eTPU channel registers and or function parameters directly Rather the CPU application can use the eTPU function APIs instead These functions can be used on any product that has an eTPU module Freescale provides an eTPU functions library that is a superset of the standard TPU library functions These along with an available C compiler make it relatively easy to port older applications to the eTPU By providing source code of the eTPU library developers are able to create customized functions for specific applications 2 1 eTPU API functions The following sections present a list of the API functions available on the Freescale website http www freescale com 2 1 1 General timing functions e Full featured and synchronized PWM e Input capture output compare Protected Output Compare e Frequency and period measurement e Pulse Period accumulate e Queued output match for complex outputs e GPIO 2 1 2 Communication functions e SPI e UART e UART with Flow Control e Proprietary Protocols 2 1 3 Motor control functio
16. ns e Stepper motor e Hall decoder e Quadrature decoder PWM Master for DC motors eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 2 Freescale Semiconductor Inc OO Generating the eTPU code e Analog sensing for DC motors e Current controller e Speed controller DC bus brake controller e PMSM vector control e ACIM V Hz control Resolver interface 2 1 4 Automotive functions Position CRANK e Engine position CAM Fuel injection e Spark ignition e Knock window e Tooth generator Each of the function above is described in detail by an application note which has a corresponding number and is available on the Freescale website http www freescale com See References 3 Generating the eTPU code This section describes the procedure to generate and download the etpu code for the PWM example Go to http www freescale com etpu click eTPU Function Selector and perform the following three steps 1 Select device PXR40 and choose Pulse Width Modulation 2 Describe the application In this case write Evaluating the etpu 3 Click the Compile button log in and choose a folder to save the Zip file to download then unzip it in a known folder Table 1 shows the files included on this package which they will be used to integrate to CW10 x Table 1 Library files ee ee ee en etpu _etpu_set etpu_set h Image of eTPU functions code etpu _etpu_set cpu e
17. ntrol PWM eTPU AN2969_PWMMAC Functions AN2970 Using the Analog Sensing for AC Motors AN2970_ASAC ASAC eTPU Function AN2971 Using the ACIM Volts per Hertz AN2971_ACIMVHZ ACIMVHZ eTPU Function AN2972 Using the PMSM Vector Control eTPU AN2972SW Function AN2973 Using the ACIM Vector Control eTPU AN2973_ACIMVC Function AN3943 Using the ACIM Resolver Interface AN3943SW 9 6 Example motor control eTPU applications Closed Loop driven by eTPU on AN2892 3 Phase BLDC Motor with Speed Closed AN2892SW Loop driven by eTPU on MCF523x AN2948 Three 3 Phase BLDC Motors with Speed AN2948SW MCF523x Table continues on the next page eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc References AN2954 BLDC Motor with Speed Closed Loop and DC Bus Break Controller driven by eTPU on MCF523x AN2954SW AN2955 DC Motor with Speed and Current Closed Loops driven by eTPU on MCF523x AN2955SW AN2957 AN3000 BLDC Motor with Quadrature Encoder and Speed Closed Loop Driven by eTPU on MCF523x AC Induction Motor Volts per Hertz Control Driven by eTPU on MCF523x AN2957SW AN3000SW AN3001 AC Induction Motor Vector Control Driven by eTPU on MPC5500 AN3001SW AN3002 Permanent Magnet Synchronous Motor Vector Control Driven by eTPU on MCF523x AN3002SW AN3005 BLDC Motor with Quadrature Encoder and Speed Closed
18. oduct or service names are the property of their respective owners 2012 Freescale Semiconductor Inc ey freescale K
19. ple1 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 e 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 Table 3 GPIO files fs_gpio h Contains definitions of various macros and functions used by the fs_gpio API siu_struct h Contains a structure definition for the SIU which is used by the API fs_gpio c 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 include mpc5500 mpc5554 h include PXR4040 h include utils etpu_util h include etpu_util h include mpc5500 fs_gpio h include fs_gpio h include etpu_set1 etpu_set1 h include _etpu_set etpu_set h include mpc5554_vars h include mpc5674f_vars h 2 Update the system clock so delete the line FMPLL SYNCR R 0x06000000 System Frequency set to 128 MHz eTPU Libraries Int
20. rocontroller designed for timing control I O handling serial communications motor control and engine control applications The eTPU is the new generation of a Time Processing Unit TPU by Freescale Besides the hardware enhancement significant improvements over TPU have been made to the accompanying software development tools these tools make the eTPU easy to use A high level C language compiler has been developed so the eTPU can be programmed using C language instead of microcode N 2012 Freescale Semiconductor Inc 4 Xs freescale eTPU function library and application interface API To program the eTPU effectively the user must have a clear understanding of how the eTPU hardware works By using the code in C language the programmer can leave the mechanics of the eTPU programming like parameter packing micro instruction packing etc to the compiler and focus more on the application logic With the help of the compiler the same symbol can be referenced by the eTPU and host software The host software can interface with eTPU functions via application programming interface API functions instead of accessing physical memory locations and registers The host application can call these API functions to interface with the eTPU The references to these API functions and symbols for parameters are resolved at compile time The implementation details of the eTPU functions are hidden from the host applicatio
21. space_loc ProjName Sources etpu _etpu_set cpu For example for the first one Click the Add icon and then choose Workspace gt lt project name gt gt Sources gt etpu gt OK See Figure 1 W Properties for pxr40_etpu_pwm X i Project References E Wer Run Debug Settings type filter text Settings Resource a Q PowerPC CPU v Compile Only Do Not Link C C Build G3 Debugging v Do not use MWClIncludes variable Build Variables Q Messages v Always Search User Paths i PowerPC Linker Discovery Options B Input User Path i AAAG Environment Logging General ProjDirPath Project_Headers Output S workspace_loc ProjName Settings bei PowerPC Compiler E ace_loc ProjName Sources etpu i Tool Chain Editor W p te S workspace_loc S ProjName Sources etpu _utils C C General i si al S workspace_loc S ProjName Sources etpu pwm j Processor Expert Input S workspace_loc H ProjName Sources etpu _etpu_set cpu 3 Optimization Figure 1 Include directories 5 Building the example code This section describes the procedure to build the example code There are two options e Reusing the examples code from the eTPU Application notes See References e 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
22. tpu_pwm_auto h Provides an interface between eTPU code and CPU code etpu _utils etpu_util c C code file for utility functions etpu _utils etpu_util h Header file for utility functions etpu pwm etpu_pwm c The C code file for the PWM API etpu pwm etpu_pwm h The header file for the PWM API include typedefs h Defines all for data types include etpu_struc h Register and bit field definitions for the eTPU include mpc5674f_vars h Variables that define some features of the MPC5674F PXR40 is a derivative of this MCU eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc 3 Integrating the etpu files to CW10 x 3 1 Function header files The API includes several header files that contain the function prototypes and define symbolic values for the initialization and return functions The following sections describe these header files briefly 3 1 1 etpu_pwm_auto h This header file is automatically generated by the eTPU compiler and defines symbols and their associated values needed to initialize the PWM function and the offset addresses in bytes for each PWM parameter It is recommended that the content of this header file should not be modified because some of the symbol values depend on other functions integrated into the function set and these may change depending on the function set used The standard names of these interfaces files are etpu_ lt func gt _auto h where lt func gt is the
23. uses the example code available from the application note AN2849 Using the eTPU Pulse Width Modulation PWM Function on http www freescale com e 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 Table 2 AN2849 files E ee ees eee pwm_example1 c 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 pwm_example1 h Rev 2 2 Example header file for MPC5500 products pwm_example2 c Rev 2 3 More complex example C code file for MPC5500 products pwm_example2 h 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_examplel c file so open it select all the text copy and replace it on the main c file The pwm_exam
24. utilities a e ETPURM Enhanced Time Processing Unit eTPU Reference Manual ETPURMAD eTPU Reference Manual Addendum AN2353 The Essentials of Enhanced Time Processing Unit AN2821 eTPU Host Interface AN2848 Programming the eTPU AN2864 General C Functions for the eTPU AN2864SW AN2897 Using the eTPU Angle Clock AN2933 Understanding the eTPU Channel Hardware eTPU Libraries Integration to CodeWarrior CW 10 x Rev 0 8 2012 Freescale Semiconductor Inc 13 References 9 2 eTPU function library and API General timing eTPU functions AN2863 eTPU General Function Set Set 1 AN2863SW_GENERALSET AN2849 Using the eTPU Pulse Width Modulation AN2849SW_PWM PWM Function AN2850 Using the General Purpose Input Output AN2850SW_GPIO GPIO eTPU Function AN2851 Using the Input Capture IC eTPU AN2851SW_IC_21 Function AN2852 Using the Output Compare OC eTPU AN2852SW_OC Function AN2854 Using the Synchronized Pulse Width AN2854SW Modulation eTPU Function AN2857 Using the Queued Output Match QOM AN2857SW_QOM eTPU Function AN2858 Using the Period and Pulse Accumulator AN2858SW PPA eTPU Function 9 3 eTPU function library and API Communication eTPU functions AN2863 eTPU General Function Set Set 1 AN2863SW_GENERALSET AN2847 Using the Serial Peripheral Interface AN2847SW_SPI SPI eTPU Function AN2853 Using the Universal Asynchronous
25. x Rev 0 8 2012 12 Freescale Semiconductor Inc Conclusion fs_etpu_init Configure the eTPU engine copy code and globals fs_etpu_apil_init Assign one channel to run a function fs_etpu_api2_ init Assign one channel to run a function configure SIU_pads Assign pads for eTPU fs timer start Start eTPU and eMIOS timers 8 Conclusion This application note describes how to integrate the eTPU libraries into a stationary based CW10 x project to use the eTPU function It also describes how to use the eTPU GCT and illustrates its use with working PWM examples The simple C interface routines of the eTPU PWM function enable easy implementation of the PWM function in applications The routines are aimed at the PXR40 family of devices but they can be used with any device that has an eTPU The benefit of the eTPU host interface design is to isolate any hardware dependency from the application software by means of the host interface API functions In the eTPU host interface design all the interactions between host and eTPU are encapsulated in the interface API functions With this interface design the implementation of the low level driver can be hidden from the host application 9 References Numerous examples of documents are available in the general set and APIs available on http www freescale com The following subsections categorically list these documents 9 1 General documentation and

Download Pdf Manuals

image

Related Search

Related Contents

Acer Iconia W4-820-Z3742G06Aii 64GB Grey  PAsMo - INESC-ID  Ultracom sxi Installation & Service Manual Boilers - Glow-worm  1769-L24ER-QBFC1B Technical Spesifications - M-SAMC  iOptron 8401 User's Manual  PYLE Audio PWLB805 User's Manual  Dicota Harbour 2.0  Philips Airstyler HP8665/81  

Copyright © All rights reserved.
Failed to retrieve file