<?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>NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72700/nrf52820-comp-issue</link><description>Hello everyone! 
 I have some issue with the comparator module on the nrf52820 chip. 
 We need to compare one of external analog signal the 1.8V internal reference source. (But other variants – 1.2V / 2.4V don’t work either) 
 When I set 0 Volt on the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Mar 2021 15:57:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72700/nrf52820-comp-issue" /><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/300755?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 15:57:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3d5527e-2ee3-4523-a57d-0ace761d562d</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="Ernst Smirnov"]Thank you very very much!!&amp;nbsp; Now it works like a charm![/quote]
&lt;p&gt;No problem at all, Ernst! I am glad to hear that it is now working as intended :)&amp;nbsp;&lt;/p&gt;
[quote user="Ernst Smirnov"]&lt;p&gt;Could you please explain a bit why definitely 63 if it&amp;#39;s possible?&lt;/p&gt;
&lt;p&gt;I tried to find it in the documentation, but I couldn&amp;#39;t do that.&lt;/p&gt;[/quote]
&lt;p&gt;The VDOWN and VUP values are the thresholds the COMP peripheral uses as reference, which is set by configuring the THDOWN and THUP in the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52820%2Fcomp.html&amp;amp;anchor=register.TH"&gt;TH register&lt;/a&gt;. Each of them hold the value of 0-63, as indicated in the documentation. So, unless these are set to 63, you are not comparing it against the full chosen reference voltage, which is 1.8V.&lt;/p&gt;
[quote user="Ernst Smirnov"]Many thanks Karl, for your time. It&amp;#39;s really helpful for us![/quote]
&lt;p&gt;I am happy to help, Ernst!&lt;br /&gt;&lt;br /&gt;Please do not hesitate to open a new ticket if you should encounter any issues or questions in the future.&lt;br /&gt;&lt;br /&gt;Good luck with your development!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/300746?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 15:31:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8031fef-aa57-41ff-a674-d89892e20db6</guid><dc:creator>Ernst Smirnov</dc:creator><description>&lt;p&gt;Hello Karl!&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/300605#300605"]f you want the reference level to be at exactly 1.8V with no hysteresis, please change them both to the value 63[/quote]
&lt;p&gt;Yes! &lt;/p&gt;
&lt;p&gt;Thank you very very much!!&amp;nbsp; Now it works like a charm!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you please explain a bit why definitely 63 if it&amp;#39;s possible?&lt;/p&gt;
&lt;p&gt;I tried to find it in the documentation, but I couldn&amp;#39;t do that.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Many thanks Karl, for your time. It&amp;#39;s really helpful for us!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Ernst&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/300605?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 09:03:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1368025-4b9a-4813-bd65-efc90d0fad2e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Ernst,&lt;/p&gt;
[quote user="Ernst Smirnov"]&lt;p&gt;Yes, I just checking the value of the result register after starting the NRF_COMP_TASK_SAMPLE task. &lt;/p&gt;
&lt;p&gt;Is it incorrect?&lt;/p&gt;[/quote]
&lt;p&gt;No, this is fine. I was just wondering whether you were using the events as well.&lt;/p&gt;
[quote user="Ernst Smirnov"]Sure! I start a debug session and put a break point to one of these lines. After that I adjust of a power source and so I can see comparison result has changed.[/quote][quote user="Ernst Smirnov"]I see it on the debug session. If the voltage of the input is higher than 0V I get the first branch of the debug condition only. &lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;However, as soon as I decrease that to zero&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; - I get the second branch immediately.[/quote]
&lt;p&gt;Thank you for clarifying, this makes it a lot clearer, and I now understand how you are using this for debugging with breakpoints only, and not as a way to monitor the value of &amp;#39;a&amp;#39; - I just had to make sure.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I see now that you do never &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52820%2Fcomp.html&amp;amp;anchor=unique_559514688"&gt;set your TH registers&lt;/a&gt; - I&amp;#39;m sorry that I missed this the first time I looked through your code. You are currently not setting the TH register, which the VUP and VDOWN is derived from. Their default value is 0, which means your thresholds place at 1.8V/64 = 0.028 V. This could be why you are seeing the change immediately after manually increasing the voltage. If you want the reference level to be at exactly 1.8V with no hysteresis, please change them both to the value 63, so that the threshold is placed at 1.8V.&lt;br /&gt;You can set your TH register by using the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fgroup__nrf__comp__hal.html&amp;amp;anchor=ga5f466f721863baa3765b907d11c63703"&gt;nrf_comp_th_set function&lt;/a&gt;.&lt;br /&gt;Please try this, and let me know if it resolves your issue! :)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If this does not resolve your issue, could you possibly send me a stripped down version of the project, so I may test this on my end, and see if I am able to reproduce the issue?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/299871?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 15:17:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4449b70-eda7-435f-ab15-8319e63a77e3</guid><dc:creator>Ernst Smirnov</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299838#299838"]No problem at all, I am happy to help! :)&amp;nbsp;[/quote]
&lt;p&gt;I&amp;#39;m glad to see it, thank you) &lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299838#299838"]Are you using the UP, DOWN, and CROSS events in your testing, or are you only checking the value of the result register through the nrf_comp_result_get function?[/quote]
&lt;p&gt;Yes, I just checking the value of the result register after starting the NRF_COMP_TASK_SAMPLE task. &lt;/p&gt;
&lt;p&gt;Is it incorrect?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299838#299838"]Could you explain the intent behind the debug section of your&amp;nbsp;COINCELL_vUpdate function? I am not sure I understand its purpose / what you might be using this for.[/quote]
&lt;p&gt;Sure! I start a debug session and put a break point to one of these lines. After that I adjust of a power source and so I can see comparison result has changed. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299838#299838"]How did you verify/check that the output of the comparison always was 1 when the voltage of the input was higher than 0V?[/quote]
&lt;p&gt;I see it on the debug session. If the voltage of the input is higher than 0V I get the first branch of the debug condition only. &lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;However, as soon as I decrease that to zero&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; - I get the second branch immediately.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299838#299838"]Looking forward to resolving this issue together.[/quote]
&lt;p&gt;Many thanks for your concern, Karl! &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;With kind regards&lt;/p&gt;
&lt;p&gt;Ernst&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/299838?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 14:26:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97225401-2f58-4778-a4d3-f6ef4aee22ad</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Ernst,&lt;/p&gt;
[quote user="Ernst Smirnov"]Many thanks for the answer![/quote]
&lt;p&gt;No problem at all, I am happy to help! :)&amp;nbsp;&lt;/p&gt;
[quote user="Ernst Smirnov"]I&amp;#39;ve tried to do that, but I still don&amp;#39;t see any errors.[/quote][quote user="Ernst Smirnov"]I use an oscilloscope connected to the measurement pin and a &lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;laboratory power supply&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;#39;s &lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;voltmeter.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;[/quote][quote user="Ernst Smirnov"]&lt;p&gt;&lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;Yes, sure. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en"&gt;&lt;span&gt;&lt;span&gt;I&amp;#39;ve attached that code bellow.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Thank you for clarifying, this is very helpful.&lt;br /&gt;&lt;br /&gt;Are you using the UP, DOWN, and CROSS events in your testing, or are you only checking the value of the result register through the nrf_comp_result_get function?&lt;/p&gt;
&lt;p&gt;Could you explain the intent behind the debug section of your&amp;nbsp;COINCELL_vUpdate function? I am not sure I understand its purpose / what you might be using this for.&lt;br /&gt;How did you verify/check that the output of the comparison always was 1 when the voltage of the input was higher than 0V?&lt;/p&gt;
[quote user="Ernst Smirnov"]Have a nice day![/quote]
&lt;p&gt;Thank you for saying that - I hope you have a nice day as well!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/299678?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 08:33:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98231089-475e-4bcd-ac78-d7b23a30366e</guid><dc:creator>Ernst Smirnov</dc:creator><description>&lt;p&gt;Hello, Karl!&lt;/p&gt;
&lt;p&gt;Many thanks for the answer!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299472#299472"]Are there any errors being generated when your program is running?&lt;br /&gt;Could you ensure that DEBUG is defined in your preprocessor defines, like shown in the included image?[/quote]
&lt;p&gt;I&amp;#39;ve tried to do that, but I still don&amp;#39;t see any errors.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299472#299472"]Could you also tell me how you are measuring / monitoring the voltage you are applying to the chosen compare pin, so that you know that it is exactly 0.1 V?[/quote]
&lt;p&gt;I use an oscilloscope connected to the measurement pin and a &lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;laboratory power supply&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;#39;s &lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;voltmeter. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/72700/nrf52820-comp-issue/299472#299472"]It would also be very helpful to see the your code here, particularly for the initiation and configuration of the comp peripheral.&lt;br /&gt;Please use the &amp;quot;Insert-&amp;gt;Code&amp;quot; option when sharing code here on DevZone.[/quote]
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;Yes, sure. &lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b ChMk0b"&gt;&lt;span&gt;I&amp;#39;ve attached that code bellow.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//--------------------------------------------------------------------------------------------------
void COINCELL_vInit(void)
{
  nrf_comp_ref_set(NRF_COMP_REF_Int1V8);
  nrf_comp_main_mode_set(NRF_COMP_MAIN_MODE_SE);
  nrf_comp_speed_mode_set(NRF_COMP_SP_MODE_High);
  nrf_comp_hysteresis_set(NRF_COMP_HYST_NoHyst);
  nrf_comp_input_select(NRF_COMP_INPUT_0);
  nrf_comp_enable();
  
  nrf_comp_task_trigger(NRF_COMP_TASK_START);
  while(!nrf_comp_event_check(NRF_COMP_EVENT_READY));
}

//--------------------------------------------------------------------------------------------------
void COINCELL_vUpdate(void)
{
  nrf_comp_task_trigger(NRF_COMP_TASK_SAMPLE);
  //sCoincell.bCellAboveTresshold = (nrf_comp_result_get() &amp;gt; 0) ? bTRUE : bFALSE;

  // Debug only section 
  uint32_t a = nrf_comp_result_get();
  if (a)
  {
    a = 1;
  }
  else 
  {
    a = 1;
  }
  // ------------
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Many thanks for helping!&lt;/p&gt;
&lt;p&gt;Have a nice day!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Ernst&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52820 COMP issue</title><link>https://devzone.nordicsemi.com/thread/299472?ContentTypeID=1</link><pubDate>Fri, 12 Mar 2021 13:07:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63fa86c0-2048-4b0f-89b4-69ef0c920f24</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Ernst,&lt;/p&gt;
[quote user=""]&lt;p&gt;It seems for me there are some problems with internal reference source.&lt;/p&gt;
&lt;p&gt;We develop the software for the nrf52820&amp;nbsp; mcu but at this moment we haven&amp;#39;t received our boards and use the nrf52833 development kit for&amp;nbsp; debug.&lt;/p&gt;[/quote]
&lt;p&gt;Good work debugging it with differential mode, this is very helpful! I have never heard of this being an issue before - the emulation of the nRF52820 on the nRF52833 is very straight forward, since the nRF52820 is a subset of the nRF52833.&lt;br /&gt;&lt;br /&gt;Are there any errors being generated when your program is running?&lt;br /&gt;Could you ensure that DEBUG is defined in your preprocessor defines, like shown in the included image?&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/0525.enabling_5F00_debug_5F00_SES.PNG" /&gt;&lt;br /&gt;Enabling DEBUG in the preprocessor defines will output a detailed error message to your logger backend, in the case that a non-NRF_SUCCESS error is passed to an APP_ERROR_CHECK.&lt;br /&gt;&lt;br /&gt;Could you also tell me how you are measuring / monitoring the voltage you are applying to the chosen compare pin, so that you know that it is exactly 0.1 V?&lt;br /&gt;&lt;br /&gt;It would also be very helpful to see the your code here, particularly for the initiation and configuration of the comp peripheral.&lt;br /&gt;Please use the &amp;quot;Insert-&amp;gt;Code&amp;quot; option when sharing code here on DevZone.&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>