<?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>Using NRF_Connect Zephyr with the Comparator interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78257/using-nrf_connect-zephyr-with-the-comparator-interrupt</link><description>I am trying to set up the nRF52840DK to interrupt on the comparator input on A0 going above the threshold. I figured, I think, how to set the comparator up but I am havin trouble connecting the interrupt to the Zephyr interrupt. Looking at the examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Aug 2021 14:52:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78257/using-nrf_connect-zephyr-with-the-comparator-interrupt" /><item><title>RE: Using NRF_Connect Zephyr with the Comparator interrupt</title><link>https://devzone.nordicsemi.com/thread/323808?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 14:52:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:954e6eb1-bd03-492c-81de-594d038b5985</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;No problem. I discussed the issue with the team now and they are going to address it in a future release. This is mainly a problem when using non-Zephyr drivers where developers have to set up the IRQ handler by themselves. &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using NRF_Connect Zephyr with the Comparator interrupt</title><link>https://devzone.nordicsemi.com/thread/323787?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 13:44:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dceb1a1-1f21-4682-8f36-b3886d2d851d</guid><dc:creator>IanAber</dc:creator><description>&lt;p&gt;I see the problem. Well caught. I added the line to set the priority to 5 and now the interrupt gets connected and&amp;nbsp;it is triggered correctly.&lt;/p&gt;
&lt;p&gt;Many thanks for the super quick responses.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using NRF_Connect Zephyr with the Comparator interrupt</title><link>https://devzone.nordicsemi.com/thread/323687?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 10:00:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ce0d4a6-2ac2-4044-9fb8-4b5d589de480</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes sorry, the pin number was wrong in my example. I didn&amp;#39;t realize pin input was expressed as an index between 0-7. I thought you were supposed specify the actual GPIO pin number (P0.2 is assigned A0 on the 52840).&lt;/p&gt;
&lt;p&gt;The NRF_COMP_INPUT_n symbols defined in nrf_comp.h can be used instead.&lt;/p&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#4ec9b0;"&gt;nrfx_comp_config_t&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;comp_config&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;NRFX_COMP_DEFAULT_CONFIG&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(NRF_COMP_INPUT_0);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;With regards to the fault you encountered, it turns out the OS is adding an offset to the input priority as you can see here &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/0944459b5b622048a08ad1f8cf8a044c135fd0d3/arch/arm/core/aarch32/irq_manage.c#L80"&gt;link&lt;/a&gt; that causes the input priority to get out of range which cause an assertion to be raised. You can work around this you can increase priority to &amp;#39;5&amp;#39; as shown below. &lt;/p&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:#4ec9b0;"&gt;nrfx_comp_config_t&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;comp_config&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;NRFX_COMP_DEFAULT_CONFIG&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(NRF_COMP_INPUT_0);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;comp_config&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;.&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;interrupt_priority&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;5&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The reason it worked fine in the first sample is that the offset was only &amp;#39;1&amp;#39;, while it&amp;#39;s &amp;#39;2&amp;#39; when you use Zigbee.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s still not clear to me why Zephyr is changing the priority value. I will look more into that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using NRF_Connect Zephyr with the Comparator interrupt</title><link>https://devzone.nordicsemi.com/thread/323627?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 04:04:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abdf836f-3335-4c4a-baeb-1c8f31ab1f4d</guid><dc:creator>IanAber</dc:creator><description>&lt;p&gt;Many thanks Vidar. I got your sample running. I had to change the definition for the port number to match the AIN0 port on the 52840 but then it worked fine. I then took your sample and tried to insert it into my program but I am running into an issue with the&amp;nbsp;IRQ_CONNECT function. I am trying to use this with what is basically the Zigbee light switch sample using the ZBOSS zigbee stack. As soin as I call the IRA_CONNECT function the system faults and restarts.&lt;/p&gt;
&lt;p&gt;Is there some detail around how to make interrupts work with the ZBOSS stack?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using NRF_Connect Zephyr with the Comparator interrupt</title><link>https://devzone.nordicsemi.com/thread/323577?ContentTypeID=1</link><pubDate>Thu, 05 Aug 2021 14:25:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66ae5a5e-f0cd-4cbc-9569-1445aa371731</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I understand the confusion. The board files don&amp;#39;t seem to include any entry for the comparator, so we can&amp;#39;t use the device tree labels like we did for the gpiote. Instead you will have to rely on hardcoded values as shown in my project below.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;nrfx sample with COMP driver&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0003.comp_5F00_sample.zip"&gt;devzone.nordicsemi.com/.../0003.comp_5F00_sample.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The IRQn number can be found in the nrf52840.h header: &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/b5399066bd7f3dc32ee15510d06ef7137bcacf36/mdk/nrf52840.h#L105"&gt;https://github.com/NordicSemiconductor/nrfx/blob/b5399066bd7f3dc32ee15510d06ef7137bcacf36/mdk/nrf52840.h#L105&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>