<?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 Combine bits from various registers into a virtual port in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280599#M20286</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure this is a fairly straightforward answer, but it is currently beyond my capability. I have a system that uses the three I/O ports on an MC9S08SE8. The system's I/O ports are made up of a variety of the I/O pins on the MC9S08SE8. Below is an example of this. Although I would have liked to, I was unable to use the entire Port B for LEDs on my system. The last LED is on Port C.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define SRC1_LED PTBD_PTBD4&lt;/P&gt;&lt;P&gt;#define SRC2_LED PTBD_PTBD5&lt;/P&gt;&lt;P&gt;#define SRC3_LED PTBD_PTBD6&lt;/P&gt;&lt;P&gt;#define SRC4_LED PTBD_PTBD7&lt;/P&gt;&lt;P&gt;#define MON1_LED PTBD_PTBD1&lt;/P&gt;&lt;P&gt;#define MON2_LED PTBD_PTBD2 &lt;/P&gt;&lt;P&gt;#define MON3_LED PTBD_PTBD3&lt;/P&gt;&lt;P&gt;#define MONO_LED PTCD_PTCD7&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I programmatically combine these definitions and refer to them as one 'virtual port'? I initially thought a structure would do it but I don't know how to assign the definitions as members of the structure. Structures are a new concept for me anyway.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Aug 2013 21:06:55 GMT</pubDate>
    <dc:creator>danielhembree</dc:creator>
    <dc:date>2013-08-28T21:06:55Z</dc:date>
    <item>
      <title>Combine bits from various registers into a virtual port</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280599#M20286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure this is a fairly straightforward answer, but it is currently beyond my capability. I have a system that uses the three I/O ports on an MC9S08SE8. The system's I/O ports are made up of a variety of the I/O pins on the MC9S08SE8. Below is an example of this. Although I would have liked to, I was unable to use the entire Port B for LEDs on my system. The last LED is on Port C.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#define SRC1_LED PTBD_PTBD4&lt;/P&gt;&lt;P&gt;#define SRC2_LED PTBD_PTBD5&lt;/P&gt;&lt;P&gt;#define SRC3_LED PTBD_PTBD6&lt;/P&gt;&lt;P&gt;#define SRC4_LED PTBD_PTBD7&lt;/P&gt;&lt;P&gt;#define MON1_LED PTBD_PTBD1&lt;/P&gt;&lt;P&gt;#define MON2_LED PTBD_PTBD2 &lt;/P&gt;&lt;P&gt;#define MON3_LED PTBD_PTBD3&lt;/P&gt;&lt;P&gt;#define MONO_LED PTCD_PTCD7&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I programmatically combine these definitions and refer to them as one 'virtual port'? I initially thought a structure would do it but I don't know how to assign the definitions as members of the structure. Structures are a new concept for me anyway.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Aug 2013 21:06:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280599#M20286</guid>
      <dc:creator>danielhembree</dc:creator>
      <dc:date>2013-08-28T21:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combine bits from various registers into a virtual port</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280600#M20287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think I have the full answer but I'd imagine it would be possible using #defines or a 16 bit variable and the use of a structure might be overkill? Either way I think your code will need intelligence so as to know which actual port to write the virtual port value to. Thus something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if the bit corresponding to MONO_LEDPTCD_PTCD7 is set&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write a 1 in bit 7 OR'd with port c&lt;/P&gt;&lt;P&gt;&amp;nbsp; else /* MONO_LEDPTCD_PTCD7 is reset */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; write a 0 in bit 7 etc&lt;/P&gt;&lt;P&gt;&amp;nbsp; write the remaining virtual port values to port d&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps! :-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 07:39:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280600#M20287</guid>
      <dc:creator>iansmusical</dc:creator>
      <dc:date>2013-08-29T07:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Combine bits from various registers into a virtual port</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280601#M20288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Daniel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;did you get to try Ian's suggestion?&lt;/P&gt;&lt;P&gt;Please don't forget to keep us posted, we'd like to know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Monica.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 22:18:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280601#M20288</guid>
      <dc:creator>Monica</dc:creator>
      <dc:date>2013-09-04T22:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Combine bits from various registers into a virtual port</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280602#M20289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps I am misunderstanding the response, but I have no difficulty manipulating the bits individually. What I was originally looking for was a way to group the various and separate bits into one collection and refer to them in that way. I actually did end up using a struct to do this, but not in the way I had originally envisioned. I'm not really even sure what I did was necessary now that I think about it. Anyway, thanks for the help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Sep 2013 20:28:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Combine-bits-from-various-registers-into-a-virtual-port/m-p/280602#M20289</guid>
      <dc:creator>danielhembree</dc:creator>
      <dc:date>2013-09-05T20:28:36Z</dc:date>
    </item>
  </channel>
</rss>

