<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>problem about function calling in ISR</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17985/problem-about-function-calling-in-isr</link><description> I call some sub-routine in ISR. And I mark the ISR as &amp;quot;using 1&amp;quot;. But I find out this will lead to the error of parameters passing from ISR to the sub-routine. How come? </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: problem about function calling in ISR</title><link>https://community.arm.com/thread/42826?ContentTypeID=1</link><pubDate>Tue, 21 Sep 2004 21:04:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:73af1e0b-4623-4c25-8a21-d33cff2908e4</guid><dc:creator>Carl Armstrong</dc:creator><description>&lt;p&gt;Thank you! Both of you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problem about function calling in ISR</title><link>https://community.arm.com/thread/111065?ContentTypeID=1</link><pubDate>Tue, 21 Sep 2004 07:45:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bafffd64-f1a3-47a5-9ef3-a66f7b8c580f</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;You live and learn.&lt;br /&gt;
&lt;br /&gt;
Anyhow we both agree that a subroutine called from a routine/ISR using a given bank must &amp;quot;know&amp;quot; which bank to operate in.&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problem about function calling in ISR</title><link>https://community.arm.com/thread/102857?ContentTypeID=1</link><pubDate>Tue, 21 Sep 2004 06:10:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fba31c12-731f-4460-a904-e18e4613bdfc</guid><dc:creator>Graham Cole</dc:creator><description>&lt;p&gt;Erik,&lt;br /&gt;
&lt;br /&gt;
That is not the best way. Each function that has a &lt;b&gt;using&lt;/b&gt; will save the PSW on the stack (which is a waste). Restoring the PSW from the stack destroys any return value of type &lt;b&gt;bit&lt;/b&gt;. Using REGISTERBANK is simpler.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;pre&gt;
#pragma REGISTERBANK(1)

bit functionone(void)
{
    return( 1 );
}

void functiontwo( char c )
{
    ...
}

myISR interrupt n using 1
{
    if( functionone() ) functiontwo( &amp;#39;c&amp;#39; );
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problem about function calling in ISR</title><link>https://community.arm.com/thread/86938?ContentTypeID=1</link><pubDate>Mon, 20 Sep 2004 08:21:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:96309d30-9ba9-4a03-84a0-8553d13d0c2a</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;... interrupt using 1&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
 functionone();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void functionone (void) &lt;b&gt;using 1&lt;/b&gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: problem about function calling in ISR</title><link>https://community.arm.com/thread/42818?ContentTypeID=1</link><pubDate>Mon, 20 Sep 2004 03:17:46 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1b15d6ef-3807-4e06-b8cd-8930c850de67</guid><dc:creator>Graham Cole</dc:creator><description>&lt;p&gt;The problem is probably that the called function is assuming it will be called with the selected register bank set to something other than one.&lt;br /&gt;
&lt;br /&gt;
By default, the compiler will generate object code that accesses registers by using direct addressing. This is helpful in generating efficient code. For example, using direct addressing, it is possible to push the value of a register onto the stack using a single instruction:&lt;br /&gt;
&lt;pre&gt;
    PUSH  AR0
&lt;/pre&gt;
To generate these direct instructions, the compiler needs to know which of the four register banks will be selected when a function is called. Normally, this will be register bank zero; but, in the case of a function called from your ISR, it will be one. You can tell the compiler which register bank is to be used by means of the REGISTERBANK compiler directive.&lt;br /&gt;
&lt;br /&gt;
See: &lt;a href="http://www.keil.com/support/man/docs/c51/c51_registerbank.asp"&gt;http://www.keil.com/support/man/docs/c51/c51_registerbank.asp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>