<?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: Use of #pragma interrupt in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127848#M782</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello,&lt;BR /&gt;I think "#pragma interrupt" is only for ISRs. It instructs the compiler to generate code for interrupt functions (context saving/restoring, put an RTI instruction at the end...). Functions called from an ISR don't need "#pragma interrupt" because they behave like normal functions.&lt;BR /&gt;Correct me if i'm wrong,&lt;BR /&gt;pittbull&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Mar 2006 21:50:18 GMT</pubDate>
    <dc:creator>pittbull</dc:creator>
    <dc:date>2006-03-03T21:50:18Z</dc:date>
    <item>
      <title>Use of #pragma interrupt</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127847#M781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hello all,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm working with 56F801 DSP for AC motor control. In my current software, several functions are being called from an ISR. This is what I have:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;-----------&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;From vector jumps:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;...&amp;nbsp; jsr ISR_Function&amp;nbsp;&amp;nbsp; // jump to ISR function&amp;nbsp; ...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;-----------&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;void ISR_Function{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;#pragma interrupt warn&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SecondFunction();&amp;nbsp;&amp;nbsp;&amp;nbsp; // call SecondFunction&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;-----------&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;#pragma interrupt called&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;void SecondFunction{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;AsmFunction();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // call assembly function&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;-----------&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;#pragma interrupt called&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;asm void AsmFunction{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nop&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do something&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Questions:&lt;/DIV&gt;&lt;DIV&gt;1) are the pragmas correctly used? For some reason, I'm still getting warnings that a non-interrupt function is being called from an interrupt function.&lt;/DIV&gt;&lt;DIV&gt;2) what happens if I call SecondFunction from a non-interrupt function (say MainBackgroundTask)?&lt;/DIV&gt;&lt;DIV&gt;3) Is there any special requirement for interrupt-called assembly functions?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks!&lt;/DIV&gt;&lt;DIV&gt;Mariano&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Mar 2006 11:27:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127847#M781</guid>
      <dc:creator>mariano</dc:creator>
      <dc:date>2006-03-03T11:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Use of #pragma interrupt</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127848#M782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello,&lt;BR /&gt;I think "#pragma interrupt" is only for ISRs. It instructs the compiler to generate code for interrupt functions (context saving/restoring, put an RTI instruction at the end...). Functions called from an ISR don't need "#pragma interrupt" because they behave like normal functions.&lt;BR /&gt;Correct me if i'm wrong,&lt;BR /&gt;pittbull&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Mar 2006 21:50:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127848#M782</guid>
      <dc:creator>pittbull</dc:creator>
      <dc:date>2006-03-03T21:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Use of #pragma interrupt</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127849#M783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;According to the "Build Tools Reference" manual, regarding #pragma interrupt called:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;You should use this pragma for all functions called from #pragma interrupt enabled ISRs. This is optional for #pragma interrupt saveall enabled ISRs, since for this case, the entire context is saved.&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The idea is that the compiler saves the registers used by all the functions called by the ISR. Another option is using #pragma interrupt saveall, but don't want to save extra registers if I don't need that.&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>Sat, 04 Mar 2006 00:14:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127849#M783</guid>
      <dc:creator>mariano</dc:creator>
      <dc:date>2006-03-04T00:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Use of #pragma interrupt</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127850#M784</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 face="Courier New"&gt;Found my problem... The compiler needed to have the "#pragma interrupt called" before the very first prototype declaration. I had my first declaration in the header file as 'extern'.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;I checked the code and the compiler generates RTIs and RTSs where needed.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Summary:&lt;BR /&gt;-----------&lt;BR /&gt;From vector table:&lt;BR /&gt;&amp;nbsp;...&amp;nbsp; jsr ISR_Function()&amp;nbsp;&amp;nbsp; // jump to ISR function&amp;nbsp; ...&lt;BR /&gt;-----------&lt;BR /&gt;void ISR_Function(void){&amp;nbsp;&amp;nbsp; // my ISR function&lt;BR /&gt;&lt;STRONG&gt;#pragma interrupt warn&lt;/STRONG&gt;&amp;nbsp; &lt;FONT color="#ff0000"&gt;*** THIS ONE NEEDS TO BE HERE,&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color="#ff0000"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NOT BEFORE PROTOTYPE ***&lt;BR /&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SecondFunction();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// call SecondFunction&lt;BR /&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; &lt;FONT color="#ff0000"&gt;*** COMPILER ISSUES AN RTI HERE ***&lt;BR /&gt;&lt;/FONT&gt;-----------&lt;BR /&gt;From header file:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // header file of SecondFunction&lt;BR /&gt;&lt;STRONG&gt;#pragma interrupt called&lt;/STRONG&gt;&lt;BR /&gt;extern void SecondFunction(void);&amp;nbsp; &lt;FONT color="#ff0000"&gt;*** FOR SOME REASON,&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color="#ff0000"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PRAGMA GOES BEFORE THIS&lt;BR /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DECLARATION ***&lt;BR /&gt;&lt;/FONT&gt;-----------&lt;BR /&gt;From c file:&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;void SecondFunction(void);&amp;nbsp; &lt;FONT color="#ff0000"&gt;*** PRAGMA DOES NOT WORK&lt;BR /&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;&amp;nbsp;&amp;nbsp;BEFORE THIS DECLARATION ***&lt;/FONT&gt;&lt;BR /&gt;void SecondFunction(void){&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color="#ff0000"&gt;*** PRAGMA DOES NOT WORK&amp;nbsp;INSIDE THIS FUNCTION ***&lt;/FONT&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;.....&lt;BR /&gt;} &lt;FONT color="#ff0000"&gt;*** COMPILER ISSUES AN RTS ***&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Does this make any sense? I find it a bit strange to have to use the #pragma in the declaration that has an 'extern'. Build manual does not seem to specify this. Moreover, I could never make the #pragma work inside the function body, as explained in the manual.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Thanks for all help&lt;BR /&gt;Mariano&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Mar 2006 08:48:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Use-of-pragma-interrupt/m-p/127850#M784</guid>
      <dc:creator>mariano</dc:creator>
      <dc:date>2006-03-13T08:48:46Z</dc:date>
    </item>
  </channel>
</rss>

