<?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 Re: Problems creating a simple ISR in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127041#M455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I'm not quite sure about using the ISR function declaration to set the interrupt vector number. I'd rather see:&lt;BR /&gt;&lt;BR /&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;interrupt void tim_ch0_vector(void) {&lt;BR /&gt; PORTA = 0x55;&lt;BR /&gt; TFLG2 = 0x80;&lt;BR /&gt;}&lt;BR /&gt;#pragma CODE_SEG DEFAULT&lt;BR /&gt;&lt;BR /&gt;You're also not adding the final ingredient to the mix, which is to plug the interrupt's address into the interrupt vector table. If you're using the CW stationery, this table is located in the file vector.c. In that file, do the following:&lt;BR /&gt;&lt;BR /&gt;1) Declare your ISR&lt;BR /&gt;&lt;BR /&gt;extern void near tim_ch0_vector(void); // Declare code of ISR to be somewhere else&lt;BR /&gt;&lt;BR /&gt;2) Add address to vector table in vector.c&lt;BR /&gt;&lt;BR /&gt;const tIsrFunc_vec[] @0xFF80 = {&lt;BR /&gt;&lt;BR /&gt; UnimplementedISR, // vector 63&lt;BR /&gt; UnimplementedISR, // vector 62&lt;BR /&gt; ...&lt;BR /&gt; UnimplementedISR, // vector 9&lt;BR /&gt; tim_ch0_vector(), // vector 8 // Where the processor is to go for this int&lt;BR /&gt; UnimplementedISR, // vector 7&lt;BR /&gt; ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Aug 2006 22:28:55 GMT</pubDate>
    <dc:creator>J2MEJediMaster</dc:creator>
    <dc:date>2006-08-18T22:28:55Z</dc:date>
    <item>
      <title>Problems creating a simple ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127040#M454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using CodeWarrior 5.7.0 with an MC9S12DT256, I'm having trouble creating a simple timer interrupt. When running the following code under all three memory models, I get ILLEGAL_BP error and execution halts before the ISR ever runs. What do I need to do to get an ISR working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;#include&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* common defines and macros */
#include&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256b"

void tim_init (void) {
 TIE = 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable Tim Ch. 0
 TSCR1 = 0x80;&amp;nbsp;&amp;nbsp; // Enable Timer module
 TSCR2 = 0x80;
 TC0 = 0x0080;
}

void main(void) {
&amp;nbsp; /* put your own code here */
 
 
&amp;nbsp; DDRA = 0xFF;
&amp;nbsp; PORTA = 0x00;
 
&amp;nbsp; EnableInterrupts;
 
&amp;nbsp; tim_init();
&amp;nbsp; for(;;) {} /* wait forever */
&amp;nbsp; /* please make sure that you never leave this function */
}

#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt 8 void tim_ch0_vector(void) {
&amp;nbsp; PORTA = 0x55;
&amp;nbsp; TFLG2 = 0x80;
}
#pragma CODE_SEG DEFAULT
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2006 08:41:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127040#M454</guid>
      <dc:creator>BFarner</dc:creator>
      <dc:date>2006-08-18T08:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problems creating a simple ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127041#M455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I'm not quite sure about using the ISR function declaration to set the interrupt vector number. I'd rather see:&lt;BR /&gt;&lt;BR /&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;interrupt void tim_ch0_vector(void) {&lt;BR /&gt; PORTA = 0x55;&lt;BR /&gt; TFLG2 = 0x80;&lt;BR /&gt;}&lt;BR /&gt;#pragma CODE_SEG DEFAULT&lt;BR /&gt;&lt;BR /&gt;You're also not adding the final ingredient to the mix, which is to plug the interrupt's address into the interrupt vector table. If you're using the CW stationery, this table is located in the file vector.c. In that file, do the following:&lt;BR /&gt;&lt;BR /&gt;1) Declare your ISR&lt;BR /&gt;&lt;BR /&gt;extern void near tim_ch0_vector(void); // Declare code of ISR to be somewhere else&lt;BR /&gt;&lt;BR /&gt;2) Add address to vector table in vector.c&lt;BR /&gt;&lt;BR /&gt;const tIsrFunc_vec[] @0xFF80 = {&lt;BR /&gt;&lt;BR /&gt; UnimplementedISR, // vector 63&lt;BR /&gt; UnimplementedISR, // vector 62&lt;BR /&gt; ...&lt;BR /&gt; UnimplementedISR, // vector 9&lt;BR /&gt; tim_ch0_vector(), // vector 8 // Where the processor is to go for this int&lt;BR /&gt; UnimplementedISR, // vector 7&lt;BR /&gt; ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2006 22:28:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127041#M455</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2006-08-18T22:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problems creating a simple ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127042#M456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Using the ISR function declaration to set the interrupt vector number appears to be valid for the 9S08 (see AN2616 page 53) - but not sure about the 9S12.&amp;nbsp; The method avoids the need to modify the .PRM file with the vector information.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Aug 2006 01:30:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Problems-creating-a-simple-ISR/m-p/127042#M456</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-08-21T01:30:19Z</dc:date>
    </item>
  </channel>
</rss>

