<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF52840 DK lpcomp reads 0 (zero) no matter what voltage is applied to the input</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60554/nrf52840-dk-lpcomp-reads-0-zero-no-matter-what-voltage-is-applied-to-the-input</link><description>I want to use a comparator without interrupt. 
 The measurement is not time critical. 
 Therefore, I chose the LPCOMP. 
 For initialization I use the following code: 
 
 For reading the value I use the following code: 
 
 Although the input is approximately</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Apr 2020 14:06:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60554/nrf52840-dk-lpcomp-reads-0-zero-no-matter-what-voltage-is-applied-to-the-input" /><item><title>RE: nRF52840 DK lpcomp reads 0 (zero) no matter what voltage is applied to the input</title><link>https://devzone.nordicsemi.com/thread/246555?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 14:06:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea9cd235-75ed-4b17-99b4-4a5abf118dee</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The problem here is that the LPCOMP has not been started before you try to sample.&amp;nbsp;You need to call the following line once when enabling the LPCOMP:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_START);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK lpcomp reads 0 (zero) no matter what voltage is applied to the input</title><link>https://devzone.nordicsemi.com/thread/246408?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 08:04:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d766e5b8-f87c-451d-b2aa-6192ad841b1d</guid><dc:creator>Stefan_B</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    uint32_t ref = NRF_LPCOMP_REF_SUPPLY_1_8;
    nrf_lpcomp_config_t config;
    config.reference = (nrf_lpcomp_ref_t)ref;
    config.detection = NRF_LPCOMP_DETECT_CROSS;
    config.hyst      = LPCOMP_HYST_HYST_Hyst50mV;
    nrf_lpcomp_configure(&amp;amp;config);
    nrf_lpcomp_input_select(NRF_LPCOMP_INPUT_7);

    nrf_lpcomp_enable();

    while (true)
    {
      nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_SAMPLE); 
      lpcomp_result = (uint8_t)nrf_lpcomp_result_get();
      nrf_gpio_pin_write(BSP_BOARD_LED_1, lpcomp_result);
      NRF_LOG_INFO(&amp;quot;LPcomp: %d&amp;quot;, (int)lpcomp_result);

      NRF_LOG_FLUSH();
      nrf_delay_ms(500);
    }
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK lpcomp reads 0 (zero) no matter what voltage is applied to the input</title><link>https://devzone.nordicsemi.com/thread/246407?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 07:58:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f096ca4c-3284-4f57-912c-ec891b29513c</guid><dc:creator>Stefan_B</dc:creator><description>&lt;p&gt;I&amp;#39;ve tried different internal values. Currently I have uint32_t ref = NRF_LPCOMP_REF_SUPPLY_1_8;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK lpcomp reads 0 (zero) no matter what voltage is applied to the input</title><link>https://devzone.nordicsemi.com/thread/246403?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 07:53:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:209ecf71-3dce-45aa-aa1e-dc299264f582</guid><dc:creator>ketiljo</dc:creator><description>&lt;p&gt;The LPCOMP have two inputs, VI+ and VI- where VIN. VI+ is the external input and the VI- is the reference. The comparator will give you the value 1 only if VI+ is higher than VI-. What have you configured VI- to be connected to?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/lpcomp.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/lpcomp.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>