<?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: Basic interrupt handling in MC9S12DT256B in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Basic-interrupt-handling-in-MC9S12DT256B/m-p/160372#M5010</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just made a correction to the interrupt intialization, the vector # must be 56 in decimal (since it is 38 hexa). Even then, my code never enters into the interrupt routine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change made:-&amp;nbsp; interrupt 0x38 void my_interrupt(void)&amp;nbsp; instead of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interrupt 38 void my_interrupt(void)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Mar 2009 22:52:45 GMT</pubDate>
    <dc:creator>Aditya</dc:creator>
    <dc:date>2009-03-10T22:52:45Z</dc:date>
    <item>
      <title>Basic interrupt handling in MC9S12DT256B</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Basic-interrupt-handling-in-MC9S12DT256B/m-p/160371#M5009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm new to microprocessors and I just began writing interrupt handling for MC9S12DT256B. I contacted freescale and with their assistance, I was able to manage to generate my code for handling interrupts. (with a lot of mistakes though &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif"&gt;&lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;My requirement:-&lt;/STRONG&gt; The aim is to generate external interrupts on pins 0 and 1 of PORT P of MC9S12DT256B. The figure is shown in the attachment. The outputs of 2 NAND gates (Q and Q^) are given as inputs to pins 0 and 1 of PORT P respectively (so if 1 is high, the other is obviously low). So if the switch is pressed, say interrupt was generated on pin 1 and vice versa. So if pin 1 of PORT P interrupts, I want LED 2 to flash up and if pin 0 interrupts, I want LED 1 to flash up. In my code, I am printing character 'c' on the LCD and I just wanted to make sure that when an interrupt occurs, I show some way that I'll be able to handle it and for the same sake, I tried to stop the printing of 'c' temporarily and show the LED that was lit and resume printing 'c' after a few seconds to ensure that the interrupt was handled correctly. I'm even displaying my source code beneath, kindly help me with your expertise. This is my source code :-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;BR /&gt;#include &amp;lt;mc9s12dt256.h&amp;gt;&lt;BR /&gt;#include "pbs12dslk.h"&amp;nbsp;&lt;BR /&gt;#include "lcd.h"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;#include "SCI.h"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;#pragma LINK_INFO DERIVATIVE "mc9s12dt256"&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;/* I think I'm handling the interrupts here */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG NON_BANKED&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;interrupt 38 void my_interrupt(void)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if((PIFP &amp;amp; 0x01) &amp;gt; 0)&amp;nbsp; // if interrupt occurs on pin 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PBMCUSLK_LED1 = 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PBMCUSLK_LED2 = 0;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIFP = 0x01; // clearing the flag register&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; else if((PIFP &amp;amp; 0x02) &amp;gt; 0) // if interrupt occurs on pin 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PBMCUSLK_LED1 = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PBMCUSLK_LED2 = 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PIFP = 0x02;&amp;nbsp; // clearing the flag register&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; return;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;#pragma CODE_SEG DEFAULT&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;/* The main code starts here */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int main()&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; unsigned char cha='c';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; unsigned char *p;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; int i,j;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; p=&amp;amp;cha;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; LCDInit();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; INIT_PBMCUSLK_LEDs;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DDRP = 0x00;&amp;nbsp; //&amp;nbsp; Using all the pins of PORT P as input&lt;BR /&gt;&amp;nbsp;&amp;nbsp; PERP = 0x03;&amp;nbsp; //&lt;BR /&gt;&amp;nbsp;&amp;nbsp; PPSP = 0x03;&amp;nbsp; //&amp;nbsp; pins 0 and 1 set to be pulled down and interrupt occurs on rising edge&lt;BR /&gt;&amp;nbsp;&amp;nbsp; PIEP = 0x03;&amp;nbsp; //&amp;nbsp; pins 0 and 1 set to enable the interrupts&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; EnableInterrupts;&amp;nbsp;&amp;nbsp; // This is the part that I'm confused of, will saying EnableInterrupts; take me to the ISR mentioned above?&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; while(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LCDClearDisplay();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LCDPutString(p);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DisableInterrupts;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; return 0;&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2009 07:36:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Basic-interrupt-handling-in-MC9S12DT256B/m-p/160371#M5009</guid>
      <dc:creator>Aditya</dc:creator>
      <dc:date>2009-03-10T07:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Basic interrupt handling in MC9S12DT256B</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Basic-interrupt-handling-in-MC9S12DT256B/m-p/160372#M5010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just made a correction to the interrupt intialization, the vector # must be 56 in decimal (since it is 38 hexa). Even then, my code never enters into the interrupt routine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change made:-&amp;nbsp; interrupt 0x38 void my_interrupt(void)&amp;nbsp; instead of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interrupt 38 void my_interrupt(void)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2009 22:52:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Basic-interrupt-handling-in-MC9S12DT256B/m-p/160372#M5010</guid>
      <dc:creator>Aditya</dc:creator>
      <dc:date>2009-03-10T22:52:45Z</dc:date>
    </item>
  </channel>
</rss>

