How to run Xgate

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to run Xgate

3,192 Views
vinay
Contributor I
Hi,
 
I am using S12XDP512 with Code warrior 4.5.
I am using xgat. I want to RUN a Xgate routine forever just like While loop. ie when activating xgate by software triggerd i want to run xgate file till my program runs. is it possible that in interrupt routine we run forever loop???
                        Also what is the difference between normal function call and xgate sofware triggered call because both called by user at run time. may i write????
 
 
Pls help me about the same.
 
 
regards,
Vinay
Labels (1)
0 Kudos
4 Replies

577 Views
kef
Specialist I
It's OK to not exit from and loop in XGATE threed forever. But S12XD XGATE threads are not interruptible. If you won't exit one XGATE thread, then you won't be able to trigger other threads and service interrupts routed to XGATE. S12XE XGATE is bit different. As far a I know S12XE XGATE allows to interrupt thread by higher priority thread.
 


vinay wrote:
                        Also what is the difference between normal function call and xgate sofware triggered call because both called by user at run time. may i write????

I don't really understand the question. You can't call XGATE function from S12X. You either trigger XGATE threads by hardware interrupts (SCI, SPI etc), or write to XGSWT register from S12X and trigger from 1 to 8 XGATE software trigger threads. Even if you trigger all 8 of them, XGATE will first execute one highest priority thread, then (if you clear specific software trigger in XGATE thread) it will execute 2nd thread, then 3rd etc.
0 Kudos

577 Views
vinay
Contributor I
Thanks..
 
        That means we cant get interrupted xgate at run time of CPU12 , i mean to say that suppose i want software interrupt 0  trigger at specifice condicion then can i interrupted to xgate??
 
like
 
if(condition)
software interrupt 0 trigger of xgate;'   //which is al ready decalred by me
else
do nothing
 
is it possible ???
 
vinay
0 Kudos

577 Views
kef
Specialist I
I don't understand your question. Could you please explain better what do you want?
 
1) If you want a forever-thread on XGATE, then just loop in thread forever. But then XGATE will be unable to service any other interrupt request. Interrupts should be handled by CPU2X then. (exception: S12XE XGATE is less restrictive than S12XD XGATE).
 
2) If you want both, using XGATE to handle interrupts and sometimes to handle conditions generated by CPU12X (by triggering software triggers), then all your XGATE threads, including software trigger handlers, should be short enough to be able to process all interrupts in time.
 
0 Kudos

577 Views
Nabla69
Contributor V
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.
0 Kudos