<?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>8-bit MicrocontrollersのトピックStrange Parallel Port behavior</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Strange-Parallel-Port-behavior/m-p/299530#M20577</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, guys,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stuck with a strange Port Behavior. The code is so simple, I can't figure out what could be wrong. Please enlighten me! I'm using a MC9S08AC32 controller, programming in C - Codewarrion 10.5.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take a look at this smple code:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD0 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initializing 2 port pins:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD1 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Pin PTC0 to Output, 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD0 = 1;&amp;nbsp;&amp;nbsp; // Pin PTC1 to Input, 0 latched (but not output)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Output, latched value (zero) goes to pin (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Input, pin goes High (I have pullup) (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Same Action, Same Result (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&amp;nbsp;&amp;nbsp; // Same Action, Same Result (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the surprising part. Look at this:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD0 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initializing 2 port pins:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD1 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Pin PTC0 to Output, 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD0 = 1;&amp;nbsp;&amp;nbsp; // Pin PTC1 to Input, 0 latched (but not output)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Output, latched value (zero) goes to pin (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Input, pin goes High (I have pullup) (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD0 = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Setting the PTC0 Pin High (nothing to do with the PTC1, right?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Ohooo... !!! Pin PTC1 does NOT go Low, as expected! It seems a "1" Value crept into the latch, the pin goes HIGH!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This happens either testing the code on chip, or in Full Chip Simulation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;I must confess I can't figure out what is happening here. I'm astonished to be stuck in so simple a piece of code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Mar 2014 13:57:39 GMT</pubDate>
    <dc:creator>davila</dc:creator>
    <dc:date>2014-03-19T13:57:39Z</dc:date>
    <item>
      <title>Strange Parallel Port behavior</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Strange-Parallel-Port-behavior/m-p/299530#M20577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, guys,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm stuck with a strange Port Behavior. The code is so simple, I can't figure out what could be wrong. Please enlighten me! I'm using a MC9S08AC32 controller, programming in C - Codewarrion 10.5.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take a look at this smple code:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD0 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initializing 2 port pins:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD1 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Pin PTC0 to Output, 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD0 = 1;&amp;nbsp;&amp;nbsp; // Pin PTC1 to Input, 0 latched (but not output)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Output, latched value (zero) goes to pin (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Input, pin goes High (I have pullup) (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Same Action, Same Result (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&amp;nbsp;&amp;nbsp; // Same Action, Same Result (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the surprising part. Look at this:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD0 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Initializing 2 port pins:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD1 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Pin PTC0 to Output, 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD0 = 1;&amp;nbsp;&amp;nbsp; // Pin PTC1 to Input, 0 latched (but not output)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Output, latched value (zero) goes to pin (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&amp;nbsp;&amp;nbsp; // Setting PTC1 to Input, pin goes High (I have pullup) (AS EXPECTED)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCD_PTCD0 = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Setting the PTC0 Pin High (nothing to do with the PTC1, right?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 1;&amp;nbsp;&amp;nbsp; // Ohooo... !!! Pin PTC1 does NOT go Low, as expected! It seems a "1" Value crept into the latch, the pin goes HIGH!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PTCDD_PTCDD1 = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This happens either testing the code on chip, or in Full Chip Simulation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;I must confess I can't figure out what is happening here. I'm astonished to be stuck in so simple a piece of code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 13:57:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Strange-Parallel-Port-behavior/m-p/299530#M20577</guid>
      <dc:creator>davila</dc:creator>
      <dc:date>2014-03-19T13:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Strange Parallel Port behavior</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Strange-Parallel-Port-behavior/m-p/299531#M20578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ugh. Pins are not addresseable! Even though you write PTCDD_PTCDD1 = 1, whole PTCDD byte gets written. CPU is told to 1) read PTCDD, 2) modify required bit (PTCDD1) in PTCDD bit pattern and 3) write modified bit pattern back to PTCDD. You can't modify one bit without rewriting whole byte. Even CPU instructions like BSET or BCLR involve all 3 steps listed above: read byte, modify it, write byte back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fixing your comments:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier;"&gt;// assuming PTCDD=0 here&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier;"&gt;PTCD_PTCD0 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // latch PTCD0=0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier;"&gt;PTCD_PTCD1 = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 1) latch PTCD1=1. 2) ^^ previous line effect is abandoned, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier;"&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; // PTCD0 is now latched with &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new, courier;"&gt;value supplied externally to PTCD0 input!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make it working as expected, either 1) init whole PTCD, or 2) set pin direction to output after each single pin latch.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 21:57:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Strange-Parallel-Port-behavior/m-p/299531#M20578</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2014-03-19T21:57:20Z</dc:date>
    </item>
  </channel>
</rss>

