<?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 Re: LPC1768 Open Drain Output settings in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1437845#M48394</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I noticed that with that line of code you just mentioned, you are writing a 110’b in the &lt;EM&gt;PINMODE_OD2 &lt;/EM&gt;register and I believe that is incorrect, because that register can only be 1 or 0. In this case, the register stays with a value of 0, and that is configuring the register in &lt;EM&gt;not open drain mode&lt;/EM&gt;. Could you please try to change that value to 1?&lt;/P&gt;
&lt;P&gt;Regards, Daniel.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Apr 2022 22:34:56 GMT</pubDate>
    <dc:creator>DanielRuvalcaba</dc:creator>
    <dc:date>2022-04-01T22:34:56Z</dc:date>
    <item>
      <title>LPC1768 Open Drain Output settings</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1437209#M48388</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I am trying to use lpc1768 to have 2 pins with Open Drain output (p2.2 and p2.2) and external pull ups. When I set these pins only as output I get pulses with correct timing but when I add this line "LPC_PINCON-&amp;gt;PINMODE_OD2 |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2))" I get a weird behavior in these pins, not matching the timing and getting extra pulses.&lt;/P&gt;&lt;P&gt;My code is the next:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void Sensor::init()
{
    LPC_PINCON-&amp;gt;PINMODE_OD2 |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2));
    LPC_GPIO2-&amp;gt;FIODIR |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2)); 
    LPC_GPIO2-&amp;gt;FIOCLR |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2));
}

void Sensor::measure(void)
{
    LPC_GPIO2-&amp;gt;FIOSET |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2));
    wait_us(50);
    LPC_GPIO2-&amp;gt;FIOCLR |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2));
    wait_us(50);
    LPC_GPIO2-&amp;gt;FIOSET |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2));
    wait_us(50);
    LPC_GPIO2-&amp;gt;FIOCLR |= ((1&amp;lt;&amp;lt;1)|(1&amp;lt;&amp;lt;2));
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am doing wrong to get OpenDrain output with the correct timing?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help, Regards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 19:14:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1437209#M48388</guid>
      <dc:creator>contr2889</dc:creator>
      <dc:date>2022-03-31T19:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 Open Drain Output settings</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1437845#M48394</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I noticed that with that line of code you just mentioned, you are writing a 110’b in the &lt;EM&gt;PINMODE_OD2 &lt;/EM&gt;register and I believe that is incorrect, because that register can only be 1 or 0. In this case, the register stays with a value of 0, and that is configuring the register in &lt;EM&gt;not open drain mode&lt;/EM&gt;. Could you please try to change that value to 1?&lt;/P&gt;
&lt;P&gt;Regards, Daniel.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 22:34:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1437845#M48394</guid>
      <dc:creator>DanielRuvalcaba</dc:creator>
      <dc:date>2022-04-01T22:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 Open Drain Output settings</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1438121#M48398</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/198556"&gt;@DanielRuvalcaba&lt;/a&gt;&amp;nbsp;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I follow your advice and I changed my code to clearly set the bits in 1'b but I still have the same problem. Here you can see the test code that I implemented:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void Sensor::init()
{
    Log::info("PINSEL4: %X", LPC_PINCON-&amp;gt;PINSEL4);
    Log::info("LPC_GPIO2-&amp;gt;FIODIR: %X", LPC_GPIO2-&amp;gt;FIODIR);
    Log::info("PINMODE4: %X", LPC_PINCON-&amp;gt;PINMODE4);
    Log::info("PINMODE_OD2: %X", LPC_PINCON-&amp;gt;PINMODE_OD2);

    LPC_PINCON-&amp;gt;PINSEL4 &amp;amp;= 0xFFFFFFC3;
    LPC_GPIO2-&amp;gt;FIODIR |= 0x00000006;
    LPC_PINCON-&amp;gt;PINMODE4 |= 0x00000028;  
    LPC_PINCON-&amp;gt;PINMODE4 &amp;amp;= 0xFFFFFFEB;
    LPC_PINCON-&amp;gt;PINMODE_OD2 |= 0x00000006;

    Log::info("PINSEL4: %X", LPC_PINCON-&amp;gt;PINSEL4);
    Log::info("LPC_GPIO2-&amp;gt;FIODIR: %X", LPC_GPIO2-&amp;gt;FIODIR);
    Log::info("PINMODE4: %X", LPC_PINCON-&amp;gt;PINMODE4);
    Log::info("PINMODE_OD2: %X", LPC_PINCON-&amp;gt;PINMODE_OD2);
}
void Sensor::measure(void)
{
    LPC_GPIO2-&amp;gt;FIOSET |= 0x00000006;
    wait_us(50);
    LPC_GPIO2-&amp;gt;FIOCLR |= 0x00000006;
    wait_us(50);
    LPC_GPIO2-&amp;gt;FIOSET |= 0x00000006;
    wait_us(50);
    LPC_GPIO2-&amp;gt;FIOCLR |= 0x00000006;
    wait_us(50);
}&lt;/LI-CODE&gt;&lt;P&gt;And this is what I get in the logs:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PINSEL4: 0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; LPC_GPIO2-&amp;gt;FIODIR: 1A0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PINMODE4: 28BFC&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PINMODE_OD2: 0&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PINSEL4: 0&lt;/EM&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_GPIO2-&amp;gt;FIODIR:&lt;EM&gt; 1A6&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PINMODE4: 28BE8&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; PINMODE_OD2: 6&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then I can see that every bit is set correctly but still I got no pulses on the pins p2.1 and p2.2. Every test was made with a 10k resistor to 3.3V for pullups, but nothing happens. But&amp;nbsp; if in the method measure() I put a longer delay as wait_us(1000),&amp;nbsp;I get two pulses but with an incorrect random width.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I said before, If I set these pins as simpe outputs without opendrain, then I get two pulses with the correct width of 50us and separation of 50us.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which could be the problem here?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 04:20:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1438121#M48398</guid>
      <dc:creator>contr2889</dc:creator>
      <dc:date>2022-04-04T04:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 Open Drain Output settings</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1439162#M48411</link>
      <description>&lt;P&gt;The solution for me was not use pins p2.1 and p2.2, instead I changed them for p0.24 and p0.25 to have two pins in open drain mode.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 21:29:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-Open-Drain-Output-settings/m-p/1439162#M48411</guid>
      <dc:creator>contr2889</dc:creator>
      <dc:date>2022-04-05T21:29:19Z</dc:date>
    </item>
  </channel>
</rss>

