<?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>topic Trouble getting PIT to work in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190925#M6874</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to codewarrior and microcontrollers in general.&amp;nbsp; I'm currently trying to get a periodic interrupt with on a DEMO9S12XDT512 board (which has the MC9S12XDT512CAA chip).&amp;nbsp; I'm writing the program in C using codewarrior IDE version 5.7.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;#include &amp;lt;mc9s12xdt512.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;#pragma LINK_INFO DERIVATIVE "mc9s12xdt512"&lt;BR /&gt;&lt;BR /&gt;int count = 0;&lt;BR /&gt;&lt;BR /&gt;void main (void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp; PITCE&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x01;&lt;BR /&gt;&amp;nbsp; PITINTE&amp;nbsp; = 0x01;&lt;BR /&gt;&amp;nbsp; PITMTLD0 = 0xFF;&lt;BR /&gt;&amp;nbsp; PITMTLD1 = 0xFF;&lt;BR /&gt;&amp;nbsp; PITLD0 = 0x00;&lt;BR /&gt;&amp;nbsp; PITLD1 = 0x00;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; PITCFLMT = 0x80;&lt;BR /&gt;&amp;nbsp; EnableInterrupts;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt; {&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;interrupt 0x7A void timer_int() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count++;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PITTF = 0x01;&lt;BR /&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I'm having is that whenever I run the code the de-bugger will stop and I'll be told I have an illegal breakpoint.&amp;nbsp; As far as I'm aware this means that my interrupt is either not being called at all or is not being reset properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm confident it is PITTF that will reset the interrupt flag, however I'm not sure of the interrupt number (I believe its refered to as a vector?) is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking in the manual I noticed the accociated vector address for PIT0 is "vector base + 0x7A", which is why I chose 0x7A although this is largely just a guess.&amp;nbsp; I have read through a number of threads which suggest that the vector table might not be set up correctly, however I have used some example code with an almost identical interrupt which does not do this and functions correctly(although if this were the problem however, I would I go about setting it up correctly in C?).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Apr 2010 03:41:57 GMT</pubDate>
    <dc:creator>campbellig</dc:creator>
    <dc:date>2010-04-12T03:41:57Z</dc:date>
    <item>
      <title>Trouble getting PIT to work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190925#M6874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to codewarrior and microcontrollers in general.&amp;nbsp; I'm currently trying to get a periodic interrupt with on a DEMO9S12XDT512 board (which has the MC9S12XDT512CAA chip).&amp;nbsp; I'm writing the program in C using codewarrior IDE version 5.7.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;#include &amp;lt;mc9s12xdt512.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;#pragma LINK_INFO DERIVATIVE "mc9s12xdt512"&lt;BR /&gt;&lt;BR /&gt;int count = 0;&lt;BR /&gt;&lt;BR /&gt;void main (void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp; PITCE&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x01;&lt;BR /&gt;&amp;nbsp; PITINTE&amp;nbsp; = 0x01;&lt;BR /&gt;&amp;nbsp; PITMTLD0 = 0xFF;&lt;BR /&gt;&amp;nbsp; PITMTLD1 = 0xFF;&lt;BR /&gt;&amp;nbsp; PITLD0 = 0x00;&lt;BR /&gt;&amp;nbsp; PITLD1 = 0x00;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; PITCFLMT = 0x80;&lt;BR /&gt;&amp;nbsp; EnableInterrupts;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt; {&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;interrupt 0x7A void timer_int() {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count++;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PITTF = 0x01;&lt;BR /&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I'm having is that whenever I run the code the de-bugger will stop and I'll be told I have an illegal breakpoint.&amp;nbsp; As far as I'm aware this means that my interrupt is either not being called at all or is not being reset properly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm confident it is PITTF that will reset the interrupt flag, however I'm not sure of the interrupt number (I believe its refered to as a vector?) is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking in the manual I noticed the accociated vector address for PIT0 is "vector base + 0x7A", which is why I chose 0x7A although this is largely just a guess.&amp;nbsp; I have read through a number of threads which suggest that the vector table might not be set up correctly, however I have used some example code with an almost identical interrupt which does not do this and functions correctly(although if this were the problem however, I would I go about setting it up correctly in C?).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Apr 2010 03:41:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190925#M6874</guid>
      <dc:creator>campbellig</dc:creator>
      <dc:date>2010-04-12T03:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble getting PIT to work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190926#M6875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;interrupt &lt;STRONG&gt;N&lt;/STRONG&gt; void timer_int() {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;N is interrupt vector number, counting from the top address vector. N=0 is reset vector, N=1 is CME vector etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You speciefied 0x7A. That's lower byte of PIT0 vector address, not vector number.&amp;nbsp;PIT0 vector number is 66. But better use vector number define from the header file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;interrupt VectorNumber_Vpit0 void timer_int(void) {&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Apr 2010 13:16:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190926#M6875</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-04-12T13:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble getting PIT to work</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190927#M6876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, excellent, that sorted everything.&amp;nbsp; Thank you very much for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Apr 2010 19:56:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-getting-PIT-to-work/m-p/190927#M6876</guid>
      <dc:creator>campbellig</dc:creator>
      <dc:date>2010-04-12T19:56:29Z</dc:date>
    </item>
  </channel>
</rss>

