<?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>LPC Microcontrollers中的主题 Re: Example of how to switch pin back and forth between open drain output and comparator Input LPC80</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1863240#M56009</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;As you know that the LPC804 has ACMP module, and the ACMP input pin is multiplexed with GPIO. for example, PIO0_14/ACMP_I3/ADC_2, the pin can function as GPIO pin and ACMP_IN3 pin.&lt;/P&gt;
&lt;P&gt;you connect a capacitor to the PIO0_4 pin, when the pin is configured as ACMP_IN3 function, the pin has high impedance, you can use a current source to charge the capacitor, when it is above a threshold which is programmable, the ACMP_OUT will become high and can trigger an interrupt.&lt;/P&gt;
&lt;P&gt;If you want to discharge the capacitor, you can configure the pin as PIO0_4 and configure the pin as GPIO output and output LOW logic, which can sink the charge via a current limited resistor.&lt;/P&gt;
&lt;P&gt;It appears you program with Arduino platform, unfortunately, I am not familiar with the platform.&lt;/P&gt;
&lt;P&gt;You can use the code to configure the PIO0_14 as GPIO output&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;#define BOARD_LED_RED_POR&lt;/SPAN&gt; 0&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;#define BOARD_LED_RED_PIN 4&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV style="background-color: #ffffff; padding: 0px 0px 0px 2px;"&gt;
&lt;DIV style="color: #000000; background-color: #ffffff; font-family: 'Consolas'; font-size: 10pt; white-space: pre;"&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;BOARD_InitPins&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;/* Enables the clock for the GPIO0 module */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;SPAN&gt;kCLOCK_Gpio0&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;gpio_pin_config_t&lt;/SPAN&gt;&lt;SPAN&gt; LED_RED_config = {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; .pinDirection = &lt;/SPAN&gt;&lt;SPAN&gt;kGPIO_DigitalOutput&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; .outputLogic = 0U,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; };&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;SPAN&gt;kCLOCK_Swm&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; SWM_SetFixedPinSelect(SWM0, SWM_PINENABLE0_ACMP_I3_MASK, false);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;/* Initialize GPIO functionality on pin PIO0_13 (pin 4) */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_PORT, BOARD_LED_RED_PIN, &amp;amp;LED_RED_config);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;You can configure the pin as ACMP_IN3&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;void pinInit()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV style="background-color: #ffffff; padding: 0px 0px 0px 2px;"&gt;
&lt;DIV style="color: #000000; background-color: #ffffff; font-family: 'Consolas'; font-size: 10pt; white-space: pre;"&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;SPAN&gt;kCLOCK_Swm&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; SWM_SetFixedPinSelect(SWM0, SWM_PINENABLE0_ACMP_I3_MASK, true);&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;You can download SDK from the link:&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;A href="https://mcuxpresso.nxp.com/en/welcome" target="_blank"&gt;https://mcuxpresso.nxp.com/en/welcome&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;You can use MCUXPresso tools to compile/debug&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;Hope it can help you&lt;/P&gt;
&lt;P style="margin: 0;"&gt;BR&lt;/P&gt;
&lt;P style="margin: 0;"&gt;XiangJun Rong&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 10 May 2024 08:11:54 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2024-05-10T08:11:54Z</dc:date>
    <item>
      <title>Example of how to switch pin back and forth between open drain output and comparator Input LPC804?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1862121#M55996</link>
      <description>&lt;P&gt;I am seeking some sample code showing how to switch a pin from floating input to open drain output and back very fast.&lt;BR /&gt;&lt;BR /&gt;I have an application where I measure the time for a charge to rise from zero volts to a Comparator threshold such as 2.5V through a fixed resistor. I use this to approximate capacitance from a circuit containing a variable capacitor.&amp;nbsp; &amp;nbsp; &amp;nbsp;The way I have done this in Arduino and Rust is slightly different but I essentially have a pin wired from +3VDD&amp;nbsp; through a 10M resistor feeding&amp;nbsp; the comparator input.&amp;nbsp; Then I measure time/count it takes for the pin to rise from zero to the threshold voltage.&amp;nbsp; &amp;nbsp;Once I detect the transition event has occurred I drain the variable capacitor through the openDrain pin and loop.&amp;nbsp; I use oversampling to improve overall reading stability.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I can use two pins one as the sense pin and one as the drainPin but if I am willing to allow the drain cycle to take a&amp;nbsp; longer then I can use a single pin that switches back and forth.&amp;nbsp; &amp;nbsp;The advantage of the two pin approach with one pin acting as open Drain is that it drains the circuit faster which means I can take more samples for averaging quickly with less CPU time draining the battery but it seems like I am always running short of pins so the 1 pin version can come in handy.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The sample code below used a CPU without a analog comparator so it used logic transition levels but it is also on a much faster clock so I could detect smaller time variations.&amp;nbsp; &amp;nbsp;For the LPC804 I want to use the analog comparator with a higher transition voltage so it takes longer to reach the transition voltage and gives the LPC804 a better chance of detecting sub 1% changes charge time.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The key to make this work well with the LPC804 is being able to switch a single pin from open drain output mode to input for the analog comparator and back.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;In the LPC804 datasheet I found:&lt;/STRONG&gt;&amp;nbsp;Pin direction bits can be toggled in 9.10.1&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;In the LPC804 users manual I found the following:&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;10.5.12 GPIO port direction toggle registers Direction bits can be set by writing ones to these write-only registers. Symbol Table 150. GPIO port direction toggle register (DIRNOT0), address 0xA000 2480 bit description.&amp;nbsp; I am hoping somebody can provide C sample code for using this feature.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The samples below are only to help clarify the approach.&amp;nbsp; &amp;nbsp;I would like to write an example showing both approaches using the LPC804.&amp;nbsp; I am hoping that we find the LPC804 CPU that draws much less power can still deliver sub 1% resolution of capacitance changes even though it is running 16 times slower.&amp;nbsp; I am hoping to show that the LPC bare metal with the analog comparator yields more consistent results due to few things happening in the background and the&amp;nbsp; defined threshold of the analog comparator means we require fewer samples when averaging.&amp;nbsp; &amp;nbsp;If I can get it working with basic C then my next step is to try it with the PLU.&lt;BR /&gt;&lt;BR /&gt;- Rust example using 1 pin:&amp;nbsp;&lt;A href="https://github.com/joeatbayes/embedded-rust-examples/tree/main/ex-gpio-change-pin-direction-var-cap-read-1-pin" target="_blank" rel="noopener"&gt;https://github.com/joeatbayes/embedded-rust-examples/tree/main/ex-gpio-change-pin-direction-var-cap-read-1-pin&lt;/A&gt;&lt;/P&gt;&lt;P&gt;- Arduino C example using 1 pin:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/joeatbayes/embedded-rust-examples/blob/main/ex-gpio-change-pin-direction-var-cap-read-1-pin/arduino-pin-direction-example/arduino-pin-direction-example.ino" target="_blank" rel="noopener"&gt;https://github.com/joeatbayes/embedded-rust-examples/blob/main/ex-gpio-change-pin-direction-var-cap-read-1-pin/arduino-pin-direction-example/arduino-pin-direction-example.ino&lt;/A&gt;&lt;/P&gt;&lt;P&gt;- Rust example using 2 pin and open drain:&amp;nbsp;&lt;A href="https://github.com/joeatbayes/embedded-rust-examples/tree/main/ex-gpio-measure-time-to-change-high-to-low" target="_blank" rel="noopener"&gt;https://github.com/joeatbayes/embedded-rust-examples/tree/main/ex-gpio-measure-time-to-change-high-to-low&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 07:20:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1862121#M55996</guid>
      <dc:creator>joeatrainamp</dc:creator>
      <dc:date>2024-05-09T07:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Example of how to switch pin back and forth between open drain output and comparator Input LPC80</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1863240#M56009</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;As you know that the LPC804 has ACMP module, and the ACMP input pin is multiplexed with GPIO. for example, PIO0_14/ACMP_I3/ADC_2, the pin can function as GPIO pin and ACMP_IN3 pin.&lt;/P&gt;
&lt;P&gt;you connect a capacitor to the PIO0_4 pin, when the pin is configured as ACMP_IN3 function, the pin has high impedance, you can use a current source to charge the capacitor, when it is above a threshold which is programmable, the ACMP_OUT will become high and can trigger an interrupt.&lt;/P&gt;
&lt;P&gt;If you want to discharge the capacitor, you can configure the pin as PIO0_4 and configure the pin as GPIO output and output LOW logic, which can sink the charge via a current limited resistor.&lt;/P&gt;
&lt;P&gt;It appears you program with Arduino platform, unfortunately, I am not familiar with the platform.&lt;/P&gt;
&lt;P&gt;You can use the code to configure the PIO0_14 as GPIO output&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;#define BOARD_LED_RED_POR&lt;/SPAN&gt; 0&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;#define BOARD_LED_RED_PIN 4&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV style="background-color: #ffffff; padding: 0px 0px 0px 2px;"&gt;
&lt;DIV style="color: #000000; background-color: #ffffff; font-family: 'Consolas'; font-size: 10pt; white-space: pre;"&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;BOARD_InitPins&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;/* Enables the clock for the GPIO0 module */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;SPAN&gt;kCLOCK_Gpio0&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;gpio_pin_config_t&lt;/SPAN&gt;&lt;SPAN&gt; LED_RED_config = {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; .pinDirection = &lt;/SPAN&gt;&lt;SPAN&gt;kGPIO_DigitalOutput&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; .outputLogic = 0U,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; };&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;SPAN&gt;kCLOCK_Swm&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; SWM_SetFixedPinSelect(SWM0, SWM_PINENABLE0_ACMP_I3_MASK, false);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;/* Initialize GPIO functionality on pin PIO0_13 (pin 4) */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_PORT, BOARD_LED_RED_PIN, &amp;amp;LED_RED_config);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;You can configure the pin as ACMP_IN3&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;void pinInit()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV style="background-color: #ffffff; padding: 0px 0px 0px 2px;"&gt;
&lt;DIV style="color: #000000; background-color: #ffffff; font-family: 'Consolas'; font-size: 10pt; white-space: pre;"&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;SPAN&gt;kCLOCK_Swm&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt; SWM_SetFixedPinSelect(SWM0, SWM_PINENABLE0_ACMP_I3_MASK, true);&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;You can download SDK from the link:&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&lt;A href="https://mcuxpresso.nxp.com/en/welcome" target="_blank"&gt;https://mcuxpresso.nxp.com/en/welcome&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;You can use MCUXPresso tools to compile/debug&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;Hope it can help you&lt;/P&gt;
&lt;P style="margin: 0;"&gt;BR&lt;/P&gt;
&lt;P style="margin: 0;"&gt;XiangJun Rong&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 May 2024 08:11:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1863240#M56009</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2024-05-10T08:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Example of how to switch pin back and forth between open drain output and comparator Input LPC80</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1863789#M56011</link>
      <description>&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;Thanks for the response, You are right I like Rust, Python and Arduino but find myself wanting to switch over to ARM C just often enough to need to learn this stuff.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I got a version of the capacitance sensor working&amp;nbsp;&amp;nbsp;LPC804 using logic levels &amp;nbsp;but still want to try a&lt;BR /&gt;version with the Analog comparator just to see if it works better.&amp;nbsp; &amp;nbsp;Here is the working version:&amp;nbsp;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers/A-C-Example-for-measuring-sub-2pF-capacitance-change-using-a/td-p/1863701" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers/A-C-Example-for-measuring-sub-2pF-capacitance-change-using-a/td-p/1863701&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on what I have working already I want to do something slightly different with the analog comparator where I I have the single sense pin and do a tight loop while charging that pin through the limit resistor until it exceeds 90% of VCC then flip modes and wait in a tight loop until until it drops below 10% of VCC.&amp;nbsp; Rather than measure time for each I will see how many cycles I can complete in a given amount of time.&amp;nbsp; I think based on what you showed that I should be able&amp;nbsp; to use&amp;nbsp;&lt;/P&gt;&lt;P&gt;ACOMP_SetInputChannel(ACOMP_PERIPHERAL, ACOMP_POSITIVE_INPUT, ACOMP_NEGATIVE_INPUT);&lt;/P&gt;&lt;P&gt;to switch back and forth between the two comparisons using two separate pins with&lt;/P&gt;&lt;P&gt;voltage dividers at 0.9VCC and 0.1VCC as the compare points or I should be able to&lt;BR /&gt;switch out the comparison voltage using the DAC which would be preferrable&lt;BR /&gt;to save pins.&lt;/P&gt;&lt;P&gt;I should be able to detect the transition with:&lt;/P&gt;&lt;P&gt;if (ACOMP_GetOutputStatusFlags(ACOMP_PERIPHERAL))&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;break;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Does this make sense or is it better to reserve the analog comparator for other uses since I have the logic level version working well.&lt;/P&gt;&lt;P&gt;I tried to get the analog comparator example working on my board for several hours but it just never detected the transition even though I tried both external pins and the DAC compare.&amp;nbsp; Will go back and try it after I try what you showed me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 11 May 2024 05:31:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Example-of-how-to-switch-pin-back-and-forth-between-open-drain/m-p/1863789#M56011</guid>
      <dc:creator>joeatrainamp</dc:creator>
      <dc:date>2024-05-11T05:31:48Z</dc:date>
    </item>
  </channel>
</rss>

