Hi Kef and all,
I agree for all and have a trick if you wish to stop the FOREVER thread of the XGATE.
For S12XD XGATE let's call it XGATE v2, its real name and S12XE XGATE is version 3.
So XGATEv2 has access to all the 32KB of on-chip RAM and you can define a SHARED area between the CPU and the XGATE in RAM.
By placing a IF condition on a shared variable within the XGATEv2 thread before looping back to its beginning, you can force the IF to become false and the thread would end.
This allows you to keep total control and save energy when/if needed.
Also, the XGATEv3 has only TWO contexts between which you can switch. It's a bit like if you had 2 XGATEs. You can only interrupt the LOW priority context with the HIGH one.
Cheers,
Alban.