AN2848 Freescale Semiconductor / Motorola, AN2848 Datasheet - Page 11

no-image

AN2848

Manufacturer Part Number
AN2848
Description
Programming the eTPU
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
The design of an eTPU function should follow some general guidelines for best results:
6
The eTPU is a peripheral device within a microcontroller and is completely controlled by the host CPU.
The system engineer needs to provide a number of setup and control functions for eTPU operation. Details
of these operations are given in the Reference Manual and in the example functions. The operations
include the following steps:
Freescale Semiconductor
Optimize your source. The compiler has a sophisticated system of optimizers, but it cannot
always rewrite inefficiently written code. We will try to provide specific examples of this in a
separate application note.
The compiler recognizes code for the unique architecture of the eTPU when it encounters the
following statement:
The function is divided into threads which are distinguished by the source of the service request
that initializes the thread. The thread entries are established by a string of if…else if…else
if……else statements. The conditions in the if statements must uniquely define one or more entry
conditions according to whether the standard or alternate entry table is selected in the #pragma
statement. All entries in the table must be provided for. All entries not explicitly covered by the if
statements will be directed to the trailing else.One thread, normally entered by an initialization
HSR, sets up the channel for the function. This includes selecting the channel mode, the TCRs to
be used, and the initial input and/or output pin actions.
If the channel is to be used to request service, the thread must enable channel service requests.
In threads which are entered in response to channel or link service requests, the flag requesting the
service should be cleared before exiting the thread. If the flag is not cleared, the channel will
immediately be rescheduled for service when the thread ends. Note that exiting a thread
(executing an end) will automatically clear the HSR bits.
Use the Simulator for debugging and analyzing your code. In the situation described in the
previous bullet, the simulator will provide a warning if a channel constantly requests service due
to an un-cleared flag.
Write the code image to the eTPU Shared Code Memory.
Configure the MCU ports as required to enable the selected eTPU pins.
Set up the global eTPU registers. This includes pin filter control and Timer/ Counter Register
prescaler and control. Global interrupts may be enabled if necessary and the MISC can be setup at
this time, although it is not necessary to use the MISC during function development.
Setup the function that is assigned to each channel. This includes writing the compiler generated
function number and the initial parameters to the local function frame for the channel. The
compiler can provide all addresses automatically.
Select a high, medium, or low priority for each function. Note that this operation allows a function
to be scheduled and execute service threads. The only certain means for the host to disable an
eTPU channel is to set the priority to zero.
#pragma ETPU_function name standard/alternate @functionnum
Host Interface Design
Programming the eTPU, Rev. 0
Host Interface Design
11

Related parts for AN2848