<?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>S12 / MagniV Microcontrollers中的主题 Re: Pass Port/Pin Address to Function</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170979#M5742</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not clear how is your&amp;nbsp;function defined adn what you&amp;nbsp;expect it to return.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jun 2012 11:47:16 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2012-06-12T11:47:16Z</dc:date>
    <item>
      <title>Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170974#M5737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am interested in writing a function that takes the address of a port as its argument, so that I can write to that port from within my function. E.g&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Definition&lt;/P&gt;&lt;P&gt;void foo(unsigned char *pin) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *pin = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // ...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Call&lt;/P&gt;&lt;P&gt;foo(&amp;amp;PORTK_PK1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the compiler gives me the following error at the function call:&lt;/P&gt;&lt;P&gt;Error: C1833: Cannot take address of this object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running this code on an MC9S12XS128MAL. Can someone point me in the right direction?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2012 02:59:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170974#M5737</guid>
      <dc:creator>Dustoor</dc:creator>
      <dc:date>2012-06-09T02:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170975#M5738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pins are not addresseable, but ports are, also pin masks are known. So you may have something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void setpin(char *port, char mask)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *port |= mask;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void clearpin(char *port, char mask)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *port &amp;amp;= ~mask;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setpin(PORTK, PORTK_PK1_MASK);&lt;/P&gt;&lt;P&gt;clearpin(PORTK, PORTK_PK1_MASK);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void setpin(char *port, char pinno)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *port |= (1&amp;lt;&amp;lt;pinno);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void clearpin(char *port, char mask)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *port &amp;amp;= ~(1&amp;lt;&amp;lt;pinno);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;setpin(PORTK, 1);&lt;/P&gt;&lt;P&gt;clearpin(PORTK, 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2012 13:59:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170975#M5738</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-06-09T13:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170976#M5739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. I've tried your suggestion, but I still get the following error:&lt;/P&gt;&lt;P&gt;Type mismatch (expected 'signed char *' , given 'unsigned char')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My function prototype is:&lt;/P&gt;&lt;P&gt;short _ReadEncoder(char *ssPort, char ssPinMask);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am calling it as so:&lt;/P&gt;&lt;P&gt;motorPosition[0] = _ReadEncoder(PORTK, PORTK_PK0_MASK);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 23:36:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170976#M5739</guid>
      <dc:creator>Dustoor</dc:creator>
      <dc:date>2012-06-11T23:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170977#M5740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My fault., &amp;amp; is missing. Should be&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;setpin(&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;PORTK, 1);&lt;/P&gt;&lt;P&gt;clearpin(&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;PORTK, 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also you may need to change function argument from char *ssPort &amp;nbsp;to unsigned char *ssPort.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;motorPosition[0] = _ReadEncoder(&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;PORTK, PORTK_PK0_MASK);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 00:00:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170977#M5740</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-06-12T00:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170978#M5741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for your help once again. Placing a '&amp;amp;' and amending the function declaration allowed me to compile with no errors. However, when monitoring the pin using an oscilloscope, I found that it does not change when the function is called. Did we miss something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function declaration:&lt;/P&gt;&lt;P&gt;short _ReadEncoder(unsigned char *ssPort, char ssPinMask);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function call:&lt;/P&gt;&lt;P&gt;motorPosition[0] = _ReadEncoder(&amp;amp;PORTK, PORTK_PK0_MASK);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S I'm sure the function is actually being called, since I am also calling a legacy function and seeing its result. I've also verified that the pin is initialized and tested it using the legacy function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 09:29:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170978#M5741</guid>
      <dc:creator>Dustoor</dc:creator>
      <dc:date>2012-06-12T09:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170979#M5742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not clear how is your&amp;nbsp;function defined adn what you&amp;nbsp;expect it to return.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 11:47:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170979#M5742</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-06-12T11:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Port/Pin Address to Function</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170980#M5743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I just rechecked my function definition and found that I was setting it twice (rather than clearing first, waiting, then setting it back).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 21:46:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Pass-Port-Pin-Address-to-Function/m-p/170980#M5743</guid>
      <dc:creator>Dustoor</dc:creator>
      <dc:date>2012-06-12T21:46:22Z</dc:date>
    </item>
  </channel>
</rss>

