<?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 Pointer of PORTS in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Pointer-of-PORTS/m-p/198957#M7437</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm looking for a solution for an array like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned int LED[2]={PTAD_PTAD0, PTCD_PTCD3}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope somebody can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Nov 2008 01:35:37 GMT</pubDate>
    <dc:creator>electronicfan</dc:creator>
    <dc:date>2008-11-03T01:35:37Z</dc:date>
    <item>
      <title>Pointer of PORTS</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Pointer-of-PORTS/m-p/198957#M7437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm looking for a solution for an array like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned int LED[2]={PTAD_PTAD0, PTCD_PTCD3}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope somebody can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 01:35:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Pointer-of-PORTS/m-p/198957#M7437</guid>
      <dc:creator>electronicfan</dc:creator>
      <dc:date>2008-11-03T01:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pointer of PORTS</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Pointer-of-PORTS/m-p/198958#M7438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;First of all, I would strongly advise against using the bitfield macros PTAD_PTAD0 etc since there is plenty of undefined behavior asociated with bitfields, making your program behave randomly in case you ever port it to another compiler/CPU. Also, the Codewarrior headers with those macros don't follow ISO C, so it is best to avoid them entirely.&lt;BR /&gt;&lt;BR /&gt;I think what you are looking for is something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;typedef enum
{
  LED0 = 0x01,  /* bit masks for the port */
  LED1 = 0x02,
  LED2 = 0x04,
  ...
} LedType;

static const unsigned char LED_MASK[N] =
{
  LED0,
  LED1,
  LED2,
  ...
};

static volatile unsigned char* leds[N] =
{
  &amp;amp;PTAD,
  &amp;amp;PTCD,
  ...
};


void set_led (unsigned int n, BOOL active)
{
  if(active)
  {
    *leds[n] |= LED_MASK[n];
  }
  else
  {
    *leds[n] &amp;amp;= (unsigned char) ~LED_MASK[n];
  }
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 17:05:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Pointer-of-PORTS/m-p/198958#M7438</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-11-03T17:05:40Z</dc:date>
    </item>
  </channel>
</rss>

