English
Language : 

AN2618 Datasheet, PDF (8/23 Pages) STMicroelectronics – eTPU host interface
Host interface software
AN2618
function frame. The host needs to know the function frame for each channel, as well as the
data type and address offset for every parameter. The function frame can be obtained by
reading the eTPU channel base address register. The eTPU_C compiler provides the host
interface macros to export the offset of each function parameter; use them in #pragma
write directives to export this information.
The function parameters can be 8-bit, 16-bit, or 32-bit. The eTPU compiler can allocate
function parameters at 8-, 16-, 24-, or 32-bit boundaries. To pass 8-bit or 16-bit parameters,
the host can directly write to eTPU data memory.
Most eTPU data registers and timers are 24-bit. To pass 24-bit eTPU function parameters,
the host needs to pass a 32-bit parameter to the eTPU. Since the host cannot access eTPU
data memory on the 24-bit boundary, the host code needs to realign the parameter to the
32-bit address boundary before writing it to the function frame. It is the responsibility of the
host to ensure the function parameters are within proper range. It is also the responsibility of
the host when writing the 24-bit parameter to ensure that the upper byte on the function
frame is not corrupted. Similarly, when reading a 24 bit return value from the function frame,
the host code must mask the upper byte before returning the correct 24 bit value. To simplify
the interface code, it is recommended to access the 24-bit function parameter by using PSE
memory space. An example of the eTPU function initialization is listed in Appendix G on
page 20 (etpu_pwm_init()).
3.5
eTPU and host interactive control
Once the eTPU function is initialized, it will start execution based on the initial parameters
and input/output conditions. The eTPU function can provide the API for the host application
code to update the function parameter or change the control mode. Similarly, the host
software has to provide proper logic to handle the eTPU interrupt or DMA requests.
The software to handle the host and eTPU interaction has to cross between two different
compilers. When the host initiates the eTPU function, the data flows from the host to eTPU.
This behavior is the same as the “call by value” protocol in the standard C syntax.
Sometimes “call by reference” is desired to access eTPU function internal variables. Since
the data flow for “call by reference” has to cross both compilers, it is not directly supported
by the compilers. However, the behavior of the “call by reference” can be implemented in the
host interface software. The host interface software can pass a reference to the API function
to access the eTPU function internal variables. An example of the “call by reference”
implementation is shown in both Appendix A on page 11 and Appendix G on page 20
(etpu_pwm_getStartTime())
Some eTPU functions require host or DMA service. The eTPU software can write the CIRC
bits in the channel interrupt and data transfer request register to send the request to the host
or DMA. The interrupt service routine must be added and the DMA channel must be
configured in the host code to respond to the eTPU request.
The host interface software has to provide functions to update eTPU function parameters or
change the control mode during the normal operation. Similar to the function initialization
API, the interface API function needs to check the validity of the parameters, write them to
the eTPU data memory, and then issue the host service request to inform eTPU that the
parameters are newly updated. An example of the update PWM function parameter is
shown in Appendix G on page 20 (etpu_pwm_update()).
8/23