![Freescale Semiconductor MPC5632M Manual Download Page 927](http://html.mh-extra.com/html/freescale-semiconductor/mpc5632m/mpc5632m_manual_2330659927.webp)
MPC563XM Reference Manual, Rev. 1
Freescale Semiconductor
927
Preliminary—Subject to Change Without Notice
23.5.4
Programming Hints and Caveats
23.5.4.1
Atomic dual access after a call, return
A dual, back-to-back parameter access is not atomic after a call, a jump, or a return if they occurred in
parallel with an odd SPRAM access. It is safer to make a pair of parameter accesses that must be coherent
begin at the second instruction after a call/jump/return.
23.5.4.2
Resource polling
The use of polling while waiting for a condition or a resource (except semaphore lock) should be avoided
in order not to hang the microengine in long loops. This general programming guideline is greatly enforced
in eTPU, as a thread cannot be preempted for any reason. Safer polling, albeit with long and
indeterministic latency, can be obtained if one issues a channel link to itself and terminates the thread. The
microengine is then free to other tasks, and the next poll happens at the next time the channel is serviced.
This mechanism can be combined with finite (timed out) loops for better latency.
23.5.4.3
Changing Channel Function, Parameter Base, or Entry Table Scheme
Channel Function, Parameter Base Address and Entry Table Scheme are determined by the ETPUCxCR
register fields CFS, CPBA and ETCS. They cannot be changed when the channel is enabled. If the channel
is disabled first, one may still have service requests from the previous function, so before the channel is
enabled again one must be sure that:
•
the first thread executed in the new function is the initialization one.
•
the initialization thread of the new function clears any previously pending service request.
Follows a safe procedure for function changing:
1. disable the channel (write ETPUCxCR field CPR=00).
2. change the function configuration (ETPUCxCR fields CFS and/or CPBA and/or ETCS).
3. request the initialization thread, writing ETPUCxHSRR with the initialization HSR (channel still
disabled).
4. enable the channel (write ETPUCxCR field CPR > 0); the initialization HSR is serviced before any
other formerly pending service requests, clearing them.
23.5.4.4
Checking and Clearing Interrupts of a Stopped Engine
An Engine may be stopped with interrupts (or DMA requests) pending. This includes the case when the
Engine’s MDIS bit is set and a thread is still running: the thread will complete execution, possibly issuing
an interrupt or DMA request before the engine stops, setting the STF bit.
As soon as the engine stops the channel registers become inaccessible, issuing bus errors when accessed.
Interrupts and DMA requests can still be checked and cleared through the Global Channel Registers,
though. DMA requests can also be cleared by the hardware handshaking with the DMA controller when
the engine is stopped.