<?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: MCF52235EVB - Help with Interrupts in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139735#M2205</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hi Ornini&lt;BR /&gt;&lt;BR /&gt;The error that you are seeing is possibly due to the fact that you are returning from main when you detect that the button has been pressed.&lt;BR /&gt;&lt;BR /&gt;Often the startup code is not designed for main to actually return. It may be implemented as a jump rather than a jump to subroutine (then there is no return address on the stack). Or it may simply have no code following the main call which leads to a crash.&lt;BR /&gt;&lt;BR /&gt;Set a break point at the return line to be sure that it is really getting there and possibly toggle an LED rather than performing "return".&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Mark&lt;BR /&gt;&lt;BR /&gt;P.S. You should also have received a compiler warning since your return is not returning a value, although main is declared as int main(void). It is always important to look carefully at compiler warnings since they sometimes point out things that can really cause a program to fail.&lt;BR /&gt;In CodeWarrior you can configure the compiler to demain prototypes so that it will generate an error when it doesn't have the information to do full function checking. This should be activated since it can also avoid potential serious errors when call conventions do not match.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by mjbcswitzerland on &lt;SPAN class="date_text"&gt;2007-07-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;12:46 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jul 2007 05:42:16 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2007-07-13T05:42:16Z</dc:date>
    <item>
      <title>MCF52235EVB - Help with Interrupts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139732#M2202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi guys,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I know I've already asked it, but this is driving me crazy - I can't make it&amp;nbsp; the INTERRUPT (using SW3 - IRQ1 on the EVB) works.&lt;/DIV&gt;&lt;DIV&gt;I'm newbie, but I did everthing by the book, and with your help (THANKS again Kremer and MARK)&amp;nbsp;- and I'm sure it is something stupid, basic thing that I miss.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I really need your help. Please take a look:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is the main.c:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;/* * File:&amp;nbsp; main.c * Purpose:&amp;nbsp; sample program * */#include &amp;lt;stdio.h&amp;gt;//#include "include\m52235evb.h"#include "common.h" unsigned char stop=0;void delay(int t_end){ int i,j; for (i=0;i&amp;lt;t_end;i++) {&amp;nbsp; for(j=0;j&amp;lt;10000;j++);&amp;nbsp; }}int main(){ unsigned char i;&amp;nbsp;&amp;nbsp;&amp;nbsp; MCF_GPIO_PNQPAR = (0 | MCF_GPIO_PNQPAR_IRQ1_IRQ1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // set interrupt function on port NQ MCF_EPORT_EPPAR0 = (0 | MCF_EPORT_EPPAR_EPPA1_RISING); // IRQ1 interrupt - I TRIED RISING, FALLING, LEVEL, BOTH MCF_EPORT_EPIER0 = (0 | MCF_EPORT_EPIER_EPIE1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable IRQ1 MCF_INTC0_ICR1 =&amp;nbsp; (MCF_INTC_ICR_IL(4) | MCF_INTC_ICR_IP(4));&amp;nbsp; // set interrupt level and priority MCF_INTC0_IMRL &amp;amp;= ~(0 | MCF_INTC_IMRL_MASK1&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; | MCF_INTC_IMRL_MASKALL); // Unmask all interrupts Leds_Init();&amp;nbsp; while(1)&amp;nbsp;&amp;nbsp; // LOOP that display running LEDs on the board {&amp;nbsp; for (i=0; i&amp;lt;0x10; i++)&amp;nbsp; {&amp;nbsp;&amp;nbsp; board_led_display(i);&amp;nbsp;&amp;nbsp; delay(100);&amp;nbsp;&amp;nbsp; if (stop==1)&amp;nbsp; &lt;STRONG&gt;// SHOULD STOP THE PROGRAM when I press SW3&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&amp;nbsp;&amp;nbsp; }&amp;nbsp; }&amp;nbsp;&amp;nbsp; }&amp;nbsp; return 0;}__interrupt__ void irq_1_isr(void){ while (!(MCF_EPORT_EPPDR0 &amp;amp; MCF_EPORT_EPPDR_EPPD1)) {}; &lt;STRONG&gt;// SHOULD STOP THE PROGRAM when I press SW3&lt;/STRONG&gt;&amp;nbsp; stop=1; MCF_EPORT_EPFR0 = (uint8)(MCF_EPORT_EPFR0 | MCF_EPORT_EPFR_EPF1);}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;and this is what I've added/Changed it the mcf52235_vectors.s :&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .#define _irq_handler&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; irq_handler#define _irq_1_isr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; irq_1_isr // added this line&amp;nbsp; .&amp;nbsp; .&amp;nbsp; ..extern _irq_handler.extern _irq_1_isr&amp;nbsp;&amp;nbsp; // added this line&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .//vector41: .long _irq1_handler // Changed this linevector41: .long _irq_1_isr&amp;nbsp; // added this line&amp;nbsp; .&amp;nbsp; .&amp;nbsp; .&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by ornini on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-07-11&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;03:40 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2007 21:32:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139732#M2202</guid>
      <dc:creator>ornini</dc:creator>
      <dc:date>2007-07-11T21:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52235EVB - Help with Interrupts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139733#M2203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Did you remember to drop the processor's interrupt fence (located in the Status Register, or SR)? This is set to 0x7 on boot up, masking all interrupts.&lt;BR /&gt;&lt;BR /&gt;You need something like:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; #0x00002000,d0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.w&amp;nbsp;&amp;nbsp; d0,SR&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;(Puts 0x2000 into the SR, thus setting the interrupt mask to 0 and enabling all interrupts).&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Simon&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2007 23:50:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139733#M2203</guid>
      <dc:creator>SimonMarsden_de</dc:creator>
      <dc:date>2007-07-11T23:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52235EVB - Help with Interrupts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139734#M2204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thank you very much Simon, you really helped me out.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Now the program do respond to the SW3 (IRQ1), but I get an error message when I press the switch.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;"Exception vector name: Bus Error&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;PC where the exception happened: 0x205AE118"&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;/EM&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Do you know what is it?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jul 2007 22:47:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139734#M2204</guid>
      <dc:creator>ornini</dc:creator>
      <dc:date>2007-07-12T22:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52235EVB - Help with Interrupts</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139735#M2205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hi Ornini&lt;BR /&gt;&lt;BR /&gt;The error that you are seeing is possibly due to the fact that you are returning from main when you detect that the button has been pressed.&lt;BR /&gt;&lt;BR /&gt;Often the startup code is not designed for main to actually return. It may be implemented as a jump rather than a jump to subroutine (then there is no return address on the stack). Or it may simply have no code following the main call which leads to a crash.&lt;BR /&gt;&lt;BR /&gt;Set a break point at the return line to be sure that it is really getting there and possibly toggle an LED rather than performing "return".&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Mark&lt;BR /&gt;&lt;BR /&gt;P.S. You should also have received a compiler warning since your return is not returning a value, although main is declared as int main(void). It is always important to look carefully at compiler warnings since they sometimes point out things that can really cause a program to fail.&lt;BR /&gt;In CodeWarrior you can configure the compiler to demain prototypes so that it will generate an error when it doesn't have the information to do full function checking. This should be activated since it can also avoid potential serious errors when call conventions do not match.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by mjbcswitzerland on &lt;SPAN class="date_text"&gt;2007-07-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;12:46 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2007 05:42:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52235EVB-Help-with-Interrupts/m-p/139735#M2205</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2007-07-13T05:42:16Z</dc:date>
    </item>
  </channel>
</rss>

