Host Interface Software
4.2 eTPU Module Initialization
At the power up initialization, the eTPU peripheral hardware is configured by the host. The eTPU module
initialization includes the following steps:
1. Initialize eTPU global registers
— eTPU MISC Compare Register (ETPU_MISCCMPR)
— eTPU Module Configuration Register (ETPU_MCR)
— eTPU Time Base Configuration Register (ETPU_TBCR)
— eTPU STAC Bus Configuration Register (ETPU_STACR)
— eTPU Engine Configuration Register (ETPU_ECR)
2. Load eTPU code from flash memory to eTPU code RAM
3. Copy initial values of eTPU code global variables to eTPU data memory
Most of the information required to configure the eTPU global registers are not dependent on the eTPU
software implementation (i.e., time base, clock frequency, entry table address, etc.). The configuration
information is determined during the host peripheral configuration and resource allocation. Only the MISC
value depends on the actual eTPU software implementation; it has to be exported to the host program after
the eTPU code is compiled. The eTPU_C compiler provides a macro (::ETPUmisc) to calculate the MISC
value of the eTPU code image (see Code Example 3).
The eTPU code image is generated when the eTPU C program is compiled. To use this code in the host
program, the eTPU code image can be exported as an array of constant values. The eTPU_C compiler
provides a macro (::ETPUcode) to generate and export the eTPU code image (see Code Example 3). The
eTPU code image constant array is suitable to be included in the host source code. The host compiler
locates the eTPU code image array in the flash memory at host source code compile time. Since the eTPU
micro-engine can only fetch micro-instructions out of eTPU code memory (RAM), at the power up
initialization, the eTPU code image has to be loaded to eTPU code memory.
As it is in the standard C syntax, when the eTPU code is compiled, the global variables are allocated to the
eTPU data memory and the initial values are assigned to the corresponding memory locations. The
standard C syntax requires that all global variables are declared outside of any function. For eTPU, this
means that all global variables have to be declared outside of any execution thread. Since only the code in
a thread can be executed on eTPU, the global variable initial value assignment statements will not be
executed. The global variables cannot be initialized in the eTPU code; they must be initialized by the host.
The software statements have to be added to the host code to initialize the eTPU global variables. The
initialization values have to be exported from the eTPU compiler to host compiler. The eTPU_C compiler
provides a macro (::ETPUglobalimage) to capture initial values for all global variables and exports them as
a constant array (Code Example 4). At power up initialization, the global variable initial values are loaded
to the eTPU data memory for global variables.
The host interface macros have to be added to the eTPU code in #pragma writestatements to export
the eTPU software information to the host compiler (Code Example 3). These statements will generate
header files that contain the MISC value, eTPU code image and global variable memory image (Code
Example 4).
eTPU Host Interface, Rev. .1
Freescale Semiconductor
5