<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>S12 / MagniV Microcontrollers中的主题 Re: Simple XGATE</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139537#M2925</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;That places the XGATE vector table at a specific place in memory. You need to check the linker file (.prm) to find out where that is - there may be a conflict which meant that XGATE did not fetch the correct vector.&lt;/DIV&gt;&lt;DIV&gt;If XGATE fails to execute properly then it sends an interrupt to the CPU (which could cause an illegal_BP if not set up).&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Dec 2006 00:58:56 GMT</pubDate>
    <dc:creator>Steve</dc:creator>
    <dc:date>2006-12-13T00:58:56Z</dc:date>
    <item>
      <title>Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139528#M2916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV&gt;Im new to microcontrollers so i appologise in advance. I have a program that looks at times between events that cause an interupt in port P. I am having a lot of problems because the main processor doesnt have enough time to process the huge number of interupts as well as do its tasks. Therefore i would like to learn how to use the xgate. I have read the app notes on it and tried to adapt the SCI example. However i dont understand the SCI parts and cant get anything to work. Does anyone have a really simple ideot proof example of the xgate in operation? (I guess thats probably it)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;How do you pass variables from the code on one processor to the other? The first thing i would like the Xgate to do is store the Timer value to a variable (LastIntTime = TCNT),&amp;nbsp;which would then be used by the main processor.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Dec 2006 05:03:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139528#M2916</guid>
      <dc:creator>isabelong</dc:creator>
      <dc:date>2006-12-11T05:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139529#M2917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Can you let us know what toolchain you are using?&lt;/DIV&gt;&lt;DIV&gt;In principle sharing variables between the cores is no different to sharing variables between two different C files on the same CPU.&lt;/DIV&gt;&lt;DIV&gt;You declare a variable in one file (say main.c)&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;unsigned int LastIntTime;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;Then access it in the other (say xgate.cxgate) with&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;extern unsigned int LastIntTime;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Now both cores can read and write the variable (but be careful that both don't write at the same time).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To make your interrupt run on XGATE you take three steps. I'll show you where this happens in the SCI example since I know you have it. (This is based on CodeWarrior)&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;1. Send the interrupt to the XGATE&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;This is done by the ROUTE_INTERRUPT macro at line 32 in main.c.&lt;/DIV&gt;&lt;DIV&gt;If you want XGATE to handle the interrupts from port P change this to&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;ROUTE_INTERRUPT(PORTP_VEC, 0x81);&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;and define PORTP_VEC as &lt;EM&gt;#define PORTP_VEC&amp;nbsp; 0x8E /* vector address= $xx8E */&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;(You get the vector address from the vector table in the databook)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;2. Write the XGATE thread&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;This is equivalent to the CPU interrupt service routine so you already have it. If it is in C then you should be able to reuse it completely unless you are accessing CPU specific features. Put it in an XGATE file (with .cxgate extension). You could put it in the &lt;EM&gt;xgate.cxgate&lt;/EM&gt; file in the SCI project. Let's assume it is called&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;interrupt void PortH_thread()&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;3. Set up the XGATE vector&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;This is like setting up the CPU vector table. You need to add the name of your XGATE thread into the XGATE vector table in xgate.cxgate. In your case you put &lt;EM&gt;PortH_thread&lt;/EM&gt; at channel 47 in the XGATE vector table. This is clearly marked in the file&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;{&lt;EM&gt;PortH_thread&lt;/EM&gt;, 0x47},&amp;nbsp; // Channel 47 - Port P Interrupt&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;That's it. Now all the Port P interrupts will go to your XGATE thread. You should remove all the code for the SCI otherwise you will get the SCI interrupts as well.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To share the variable do as I suggested above and declare it in one file and access it as extern in the other.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I haven't tried this here but those are the three steps and it should work.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 00:15:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139529#M2917</guid>
      <dc:creator>Steve</dc:creator>
      <dc:date>2006-12-12T00:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139530#M2918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;One additional thing to do:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Make sure that all variables with shared access between interrupt code (either S12X or XGate )and non-interrupt code are declared "volatile".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Hardware IO registers should also be declared as "volatile".&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The C documentation explains volatile.&amp;nbsp; What it does is make sure that the C compiler always gets the current value from the variable location, and doesn't assume that it can use an old value in a register from several statements ago.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Example&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;You declare a variable in one file (say main.c)&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;U&gt;volatile&lt;/U&gt; unsigned int LastIntTime;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;Then access it in the other (say xgate.cxgate) with&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;extern &lt;U&gt;volatile&lt;/U&gt; unsigned int LastIntTime;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 02:20:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139530#M2918</guid>
      <dc:creator>SteveRussell</dc:creator>
      <dc:date>2006-12-12T02:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139531#M2919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks for help, so far i have the following but i have an Illegal_BP problem. I would just like to be able to see one of the counter going up.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;IMG src="http://www.formulastudent.strath.ac.uk/pic.JPG" /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 03:21:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139531#M2919</guid>
      <dc:creator>isabelong</dc:creator>
      <dc:date>2006-12-12T03:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139532#M2920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I can't see any particular issues with your code. I recommend you track down the cause of the illegal breakpoint - this is usually caused by code runaway which may be due to an unexpected interrupt not being handled. Use the debugger to check that the XGATE code is being executed and try to see what happens just before the Illegal_BP. You may have to initialise all of the CPU vectors if an interrupt is the source of the problem.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 17:33:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139532#M2920</guid>
      <dc:creator>Steve</dc:creator>
      <dc:date>2006-12-12T17:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139533#M2921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I have a switch to cause the interupt. The code runs ok until this interupt occurs.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Therefore I ran code, halted it, pressed the switch and then stepped it and nothing ever happens just carries on with main code. as soon as continue is hit, illegal_BP. How do I find the problem? I assume its with the xgate code since theres only a problem when an interupt occurs but i dont see anything happening with the xgate debugging windows. Should i not see the code get executed line by line when i step through.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 19:03:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139533#M2921</guid>
      <dc:creator>isabelong</dc:creator>
      <dc:date>2006-12-12T19:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139534#M2922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Good Afternoon Steve and Isabelong,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I just got an idea...&lt;/DIV&gt;&lt;DIV&gt;Isa, you say you use a switch to create the interrupt.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm thinking about rebounce and &lt;STRONG&gt;Spurious Interrupt&lt;/STRONG&gt;.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Am I crazy (frog) or it fits the profile ? It just reminds me of an old story &lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Cheers,&lt;/DIV&gt;&lt;DIV&gt;Alban.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 21:33:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139534#M2922</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2006-12-12T21:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139535#M2923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I have also used portB to trigger interupt and same problem.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 23:07:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139535#M2923</guid>
      <dc:creator>isabelong</dc:creator>
      <dc:date>2006-12-12T23:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139536#M2924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Its Working, I removed the following line, what does it do?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;//#pragma CONST_SEG XGATE_VECTORS&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Again, thanks for all your help&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2006 23:19:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139536#M2924</guid>
      <dc:creator>isabelong</dc:creator>
      <dc:date>2006-12-12T23:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139537#M2925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;That places the XGATE vector table at a specific place in memory. You need to check the linker file (.prm) to find out where that is - there may be a conflict which meant that XGATE did not fetch the correct vector.&lt;/DIV&gt;&lt;DIV&gt;If XGATE fails to execute properly then it sends an interrupt to the CPU (which could cause an illegal_BP if not set up).&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Dec 2006 00:58:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139537#M2925</guid>
      <dc:creator>Steve</dc:creator>
      <dc:date>2006-12-13T00:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139538#M2926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Got that working nicely. I had copied bits and pieces from too many example and there was a bad link somewhere. My next step was get the timer overflow interupt back in.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;interrupt 16 void TMOF() //TIMER OVERFLOW INTERRUPT&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;SecondTimer++;&lt;BR /&gt;&amp;nbsp;TFLG2_TOF = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;//CLEAR INT FLAG&lt;BR /&gt;}&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;and&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;&amp;nbsp;TSCR1 = 0x80;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//ENABLE TIMER&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;&amp;nbsp;TSCR2 = 0x84;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PRESCALER SET TO 16&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Now&amp;nbsp; i get&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;L1907: Fixup overflow in vector_16, to TMOF type 1, at offset 0x0.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Why is this?&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Dec 2006 03:13:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139538#M2926</guid>
      <dc:creator>isabelong</dc:creator>
      <dc:date>2006-12-16T03:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple XGATE</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139539#M2927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You have to make sure the function TMOF is allocated in a __NEAR_CODE section.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;ifndef __SMALL__&lt;BR /&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;#endif&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;interrupt 16 void TMOF() {&amp;nbsp;//TIMER OVERFLOW INTERRUPT&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;&amp;nbsp; // Code here&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" face="Courier New"&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000" face="Courier New"&gt;#pragma CODE_SEG DEFAUT&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;CrasyCat&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Dec 2006 17:07:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Simple-XGATE/m-p/139539#M2927</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-12-18T17:07:00Z</dc:date>
    </item>
  </channel>
</rss>

