AN2848 Freescale Semiconductor / Motorola, AN2848 Datasheet - Page 8

no-image

AN2848

Manufacturer Part Number
AN2848
Description
Programming the eTPU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Function Design – Software
Further information on the eTPU_C compiler can be obtained from Byte Craft.
A Simulator for the eTPU is available from Ash Ware, Inc. of Beaverton, Oregon. Ash Ware has had
extensive experience with simulation for the TPU, and cooperated during the development of the silicon
by co-validating the simulator. Most experienced users find that the Ash Ware stand-alone simulator is the
best way to develop their initial eTPU software. When systems require tight coupling of the eTPU and the
CPU, a full system simulator is also available for later stages of the project. For further information, please
contact Ash Ware.
5
Simple functions like the PWM described above do not require an eTPU. By simply reloading a down
counter, the hardware can sustain a PWM without service by a programmed engine. Suppose now that the
user wants not just a PWM, but a PWM implemented sine wave modulated by a feedback signal. For
example, the channel could produce a 40 kHz PWM waveform which is modulated by a 400 Hz sine wave
whose amplitude is driven by a control loop parameter. A low-pass filter and amplifier would be all that
was required to reproduce the desired 400 Hz signal. This means that the duty cycle of each period would
be determined by a sine value times an externally determined amplitude.
While a special piece of hardware could be designed to implement this function, the eTPU can handle it
quite well in software. The complete details of such a system are beyond the scope of this application note,
but it is instructive to look at the necessary design strategy. The engine in the eTPU could be given the
following equation:
HighTime =
(Amp * sin(2*PulseNumber/(PWM_frequency/Modulation_frequency))/MaxAmp
This works on a spreadsheet, and given a floating point and trig library, the compiler could produce code
for it. However, no sensible designer would write the algorithm in this way. The point is that the correct
design approach is to look through the requirement at the CPU executing the code and to design a optimal
algorithm within the constraints of the system.
8
The host compiler and linker do not require special features to use the eTPU information.
Information is provided in C compatible files and the subsequent compilation of the host project
can provide all the information for code passing and reference resolution.
The compiler compiles directly to eTPU microcode, often producing one microcode instruction
for multiple source instructions.
The mapping of entry addresses for service requests from the host or the channel hardware is
compiled from C statements in the eTPU source.
The new coding standard allows direct access to registers and other resources in the eTPU engine,
enabling the user to write “Assembly C” which provides the data flow analysis of a compiler in a
low level, assembly-like language.
Function Design – Software
Programming the eTPU, Rev. 0
Freescale Semiconductor

Related parts for AN2848