<?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>nrfx GPIOTE conflict with Zephyr GPIO API</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69057/nrfx-gpiote-conflict-with-zephyr-gpio-api</link><description>We are using the Zephyr IIS2DLPC driver to talk to that sensor from an nRF5340. This driver uses the Zephyr GPIO API to configure interrupts, which is implemented in drivers/gpio/gpio_nrfx.c. That module manages GPIOTE channels and uses hal/nordic/nrfx</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Feb 2021 07:14:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69057/nrfx-gpiote-conflict-with-zephyr-gpio-api" /><item><title>RE: nrfx GPIOTE conflict with Zephyr GPIO API</title><link>https://devzone.nordicsemi.com/thread/293889?ContentTypeID=1</link><pubDate>Thu, 11 Feb 2021 07:14:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2078d854-d658-4fca-93d8-b9541aa184a6</guid><dc:creator>Stephan Walter</dc:creator><description>&lt;p&gt;This seems to be fixed now in this commit: &lt;a href="https://github.com/nrfconnect/sdk-zephyr/commit/a86ac1f8c2a48e32ed824f0f5ea49d45ceaa345f"&gt;https://github.com/nrfconnect/sdk-zephyr/commit/a86ac1f8c2a48e32ed824f0f5ea49d45ceaa345f&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfx GPIOTE conflict with Zephyr GPIO API</title><link>https://devzone.nordicsemi.com/thread/283265?ContentTypeID=1</link><pubDate>Fri, 04 Dec 2020 09:27:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77ffb745-f47b-4d95-a9fb-774e16cf360c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="sw"]&lt;p&gt;I have come across edge vs. level triggering before and I&amp;#39;m confused about how exactly they behave and when to choose which. On top of that there is the port event and the sense mechanism. Compared to other MCU families the nRF chips seem very complicated in this regard.&lt;/p&gt;
&lt;p&gt;When should one use the sense mechanism?&lt;/p&gt;[/quote]
&lt;p&gt;The simple answer is:&lt;/p&gt;
&lt;p&gt;For accuracy; use GPIOTE IN. Where accuracy is not required, use PORT.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;GPIOTE IN will require a bit more current in sleep than a GPIO configured with SENSE (thus; it&amp;nbsp;generates a GPIOTE&amp;nbsp;PORT event).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="sw"]We have to patch the IIS2DLPC driver anyway, so we might change it to not use GPIOTE. If I understand you correctly this would mean that nrfx_gpiote can exclusively manage GPIOTE. But what would the consequence be in terms of latency, power consumption etc?[/quote]
&lt;p&gt;&amp;nbsp;GPIOTE IN will add some current to your base current, in the area of 30 uA on nRF9160 (which is very similar to nRF5340), but a high speed NRF_TIMERx peripheral will use the peripheral clock tree, thus keep that running in sleep, giving you this sleep current:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/current_consumption/doc/current_consumption.html?cp=3_0_0_3_3_0_15#unique_474202684"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/current_consumption/doc/current_consumption.html?cp=3_0_0_3_3_0_15#unique_474202684&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The above numbers are based on capture/compare mode, but for counter mode; this should not rely on the clock tree, thus you should have a much lower current consumption.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have an old sample, made&amp;nbsp;around the release of ncs v1.1.0 I believe, which uses DPPI/TIMER (cc mode; the fw times a GPIOTE IN pulse width):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/nrfx_timed_signal/src/main.c"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/nrfx_timed_signal/src/main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As of newer ncs versions: The applications Kconfig, where NRFX components are selected, is not required, nor is this config line:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/nrfx_timed_signal/prj.conf#L11"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/nrfx_timed_signal/prj.conf#L11&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hope this helps clear the DPPI vs. PPI scenario a bit.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfx GPIOTE conflict with Zephyr GPIO API</title><link>https://devzone.nordicsemi.com/thread/283176?ContentTypeID=1</link><pubDate>Thu, 03 Dec 2020 16:30:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:484ba4ad-fd71-404f-b2ae-cf46eb0870f7</guid><dc:creator>Stephan Walter</dc:creator><description>&lt;p&gt;Thanks you Hakon for the speedy reply. You wrote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Interrupt enabled pins, without edge-triggering, will be configured using the GPIOTE PORT event.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I have come across edge vs. level triggering before and I&amp;#39;m confused about how exactly they behave and when to choose which. On top of that there is the port event and the sense mechanism. Compared to other MCU families the nRF chips seem very complicated in this regard.&lt;/p&gt;
&lt;p&gt;When should one use the sense mechanism?&lt;/p&gt;
&lt;p&gt;We have to patch the IIS2DLPC driver anyway, so we might change it to not use GPIOTE. If I understand you correctly this would mean that nrfx_gpiote can exclusively manage GPIOTE. But what would the consequence be in terms of latency, power consumption etc?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfx GPIOTE conflict with Zephyr GPIO API</title><link>https://devzone.nordicsemi.com/thread/283082?ContentTypeID=1</link><pubDate>Thu, 03 Dec 2020 13:08:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb882993-3a34-4758-af63-4be661deee68</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note that the zephyr gpio driver will only use a dedicated GPIOTE IN channel if the gpio is setup with edge-triggering.&lt;/p&gt;
&lt;p&gt;Interrupt enabled pins, without edge-triggering, will be configured using the GPIOTE PORT event.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Is our understanding correct? And what is the best way to avoid these conflicts?[/quote]
&lt;p&gt;Your understanding is correct. Those two drivers don&amp;#39;t play well together, and this was unfortunately never the intention either. The normal scenario is to either use zephyr drivers for things, or use nrfx. Since zephyr&amp;#39;s gpio API doesn&amp;#39;t expose the use for GPIOTE IN events and tasks, I fully understand your situation.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you cannot get a hold of the gpio_nrfx.c::gpiote_alloc_mask (its static, and not returned anywhere), there&amp;#39;s no current good way of determining this w/o editing, other than reading the algorithm for allocation (starting from 0 and increments), and making sure your integration and the zephyr driver does not overlap. This isn&amp;#39;t very bullet proof, so be sure to comment your&amp;nbsp;implementation thoroughly..&lt;/p&gt;
&lt;p&gt;An additional test-vector: I would recommend that you also check the NRF_GPIOTE-&amp;gt;CONFIG[n] register against the reset value, just to see if someone has tried to access it:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/gpiote.html?cp=2_0_0_5_4_3_12#register.CONFIG"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf9160/gpiote.html?cp=2_0_0_5_4_3_12#register.CONFIG&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Fortunately, you do not require interrupts for your second algorithm. If you would have used interrupts; you would have had to either patch the zephyr driver, or chosen to only use nrfx.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>