<?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>Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104847/level-based-control-of-gpiote</link><description>Hi, I have a comparator acting as a UVLO, it connects to a NRF52 pin with a pull-up. The comparator also pulls down two other circuits using a diode, which in turn are connected to other NRF52 pins using pull-ups. It works well. I&amp;#39;d like if possible to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Nov 2023 16:12:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104847/level-based-control-of-gpiote" /><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/453561?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 16:12:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d34833e6-a4a1-443d-a1c5-7dfb7290ddc3</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Happy to report that the GPIO drive config is being observed and the pull-downs are also working in output mode, matching hmolesworth&amp;#39;s reply. This means I have a solution!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452940?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 08:43:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f6b2a81-ef80-4e08-a13e-71cb2c4a05c6</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Marvellous!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;My revised PCB arrives today, so I&amp;#39;ll build it and report back whether it works on the 810. I guess it will!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452906?ContentTypeID=1</link><pubDate>Mon, 30 Oct 2023 01:24:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f032246-2b71-4074-8f8d-4a3cb24cacdf</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Pull-up and pull-down resistors can be enabled on an output pin on nRF52832 and nRF52840 (others not tested) and this is a really useful feature.&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;&lt;em&gt;A pull-resistor cannot be enabled on a output device&lt;/em&gt;&amp;quot; is not correct, although the Product Specification does &lt;/span&gt;&lt;span&gt;show the pull-up and pull-down don&amp;#39;t apply to an output pin. I have pointed out this issue in older posts, but the Product Specifications were not updated.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Here are my measurement results, which prove the pullup/pull-down resistor is connected to the pin regardless
// of the input setting. nRF52832, 32MHz crystal, no 32kHz crystal, no Reset pin, SoftDevice loaded but not
// enabled, no peripherals enabled, idle. Power CR2032 coin cell, no ground other than PPK-2, no J-Link.
//
// This first table is default port settings after a reset, no changes:
//
// PPK-2  Meter  Conditions
// ====== ====== ==========
// 1.66uA 2.971V with errata workarounds, no i/o
// 1.51uA 2.985V   no errata workarounds, no i/o
//
// This Next table is port settings made after a reset, all 32 port pins identical, nothing connected to any of
// the 32 port pins, no errata applied:
//
// PPK-2  Meter   Direction    Input            Pullup         Drive Level      Sense Level    Output
// ====== ======  ==========   ==============   ============   ==============   ============== ===========
//
// 1.49uA 2.989V (PIN_OUTPUT | PIN_DISCONNECT | PIN_PULLNONE | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven Low
// 1.49uA 2.999V (PIN_OUTPUT | PIN_DISCONNECT | PIN_PULLDOWN | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven Low
// 6.47mA 2.894V (PIN_OUTPUT | PIN_DISCONNECT | PIN_PULLUP   | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven Low
// 6.47mA 2.889V (PIN_OUTPUT | PIN_CONNECT    | PIN_PULLUP   | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven Low
//
// 1.51uA 2.959V (PIN_OUTPUT | PIN_DISCONNECT | PIN_PULLNONE | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven High
// 6.42mA 2.877V (PIN_OUTPUT | PIN_DISCONNECT | PIN_PULLDOWN | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven High
// 1.53uA 2.938V (PIN_OUTPUT | PIN_DISCONNECT | PIN_PULLUP   | PIN_DRIVE_S0S1 | PIN_SENSE_OFF) Driven High
//
//
// This shows setting a port pin into active low output driven low is as good as leaving a pin floating
// when unused, with the added benefit that there is no possibility of port feedthrough if a floating pin
// drifts through the threshold.
//
// Looking at pull-up and pull down resistor values for the 32 pins:
//
//   (2.877Volts / 6.42mA) * 32 ==&amp;gt; 14.34K Ohm
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here is one of my older responses&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69827/nrf52832-power-leakage/287808"&gt;nrf52832-power-leakage&lt;/a&gt;&amp;nbsp;which&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/stian"&gt;stian&lt;/a&gt;&amp;nbsp;reported internally at the time&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452878?ContentTypeID=1</link><pubDate>Sat, 28 Oct 2023 19:27:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cefe3e7d-a406-46de-8441-1d292560cd68</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;EVENTS_DOWN = task, 0,&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;GPIO_PIN_CNF_DRIVE_S0S1&amp;nbsp;&lt;/span&gt;&lt;br /&gt;EVENTS_UP = task, 1,&amp;nbsp;&lt;span&gt;GPIO_PIN_CNF_DRIVE_S0S1&amp;nbsp;&lt;/span&gt;&lt;br /&gt;DEFAULT (OVERRIDE) =&amp;nbsp;external weak pull-down, GPIO_PIN_CNF_DRIVE_S0D1&lt;br /&gt;&lt;br /&gt;The diagram within the gpio section indicates drive_strength will be respected. I only need to add an external weak-pull down resistor.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452595?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2023 12:55:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a042f068-e4e6-44c2-a7db-d7d1fdda3257</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;
&lt;p&gt;A pull-resistor cannot be enabled on a output device, so the GPIO_PIN_CNF_PULL line does not have any effect when the GPIO is configured with GPIO_PIN_CNF_DIR_Output.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you disable, you have setup the specific GPIO to be a open-drain, commonly&amp;nbsp;used in I2C pin operation.&lt;/p&gt;
&lt;p&gt;The drive-level is set to standard-drive on &amp;#39;0&amp;#39; (output low), and disconnected on output high &amp;#39;1&amp;#39;.&lt;/p&gt;
&lt;p&gt;This means that the GPIO will float when set to &amp;#39;1&amp;#39;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You have 3 states:&lt;/p&gt;
&lt;p&gt;* EVENTS_DOWN&lt;/p&gt;
&lt;p&gt;* EVENTS_UP&lt;/p&gt;
&lt;p&gt;* &amp;quot;default state&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How do you want your GPIO(s) to be set in each of these states?&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: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452373?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 20:58:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78def3ad-bbf2-4974-951f-af2f9bbd3c08</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Been looking into it this evening. I read that GPIO config is retained when GPIOTE takes over the pin output. I&amp;#39;m unsure but making an assumption that weak pull is still operational when pin is in outmode mode. A hopeful solution is:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_GPIO-&amp;gt;PIN_CNF[CFG_PIN_POWERMANAGER_FRONT_ENABLE] = pinDisconnectInputBuffer 
    | GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos 
    | GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos 
    | GPIO_PIN_CNF_PULL_Pulldown &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos;
  
NRF_GPIOTE-&amp;gt;CONFIG[CFG_GPIOTE_POWERMANAGER_FRONT] = GPIOTE_CONFIG_OUTINIT_High &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos 
    | GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos 
    | CFG_PIN_POWERMANAGER_FRONT_ENABLE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;

NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_UP;
NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_SET[CFG_GPIOTE_POWERMANAGER_FRONT];
NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_DOWN;
NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[CFG_GPIOTE_POWERMANAGER_FRONT];

// UVLO
NRF_COMP-&amp;gt;REFSEL = UVLO_REFERENCE &amp;lt;&amp;lt; COMP_REFSEL_REFSEL_Pos;
NRF_COMP-&amp;gt;TH = UVLO_HYSTERESIS_UP &amp;lt;&amp;lt; COMP_TH_THUP_Pos | UVLO_HYSTERESIS_DOWN &amp;lt;&amp;lt; COMP_TH_THDOWN_Pos;
NRF_COMP-&amp;gt;PSEL = COMP_UVLO &amp;lt;&amp;lt; COMP_PSEL_PSEL_Pos;
NRF_COMP-&amp;gt;ENABLE = COMP_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; COMP_ENABLE_ENABLE_Pos;
NRF_COMP-&amp;gt;TASKS_SAMPLE = COMP_TASKS_SAMPLE_TASKS_SAMPLE_Trigger &amp;lt;&amp;lt; COMP_TASKS_SAMPLE_TASKS_SAMPLE_Pos;

// wait a moment for voltage to stablize
// if it doesn&amp;#39;t happen watchdog will reset
while (!NRF_COMP-&amp;gt;RESULT) {
  NRF_COMP-&amp;gt;TASKS_SAMPLE = 1;
};
NRF_COMP-&amp;gt;EVENTS_DOWN = 0;

// must come after comparator to ensure output sync
NRF_PPI-&amp;gt;CHENSET = 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD
  | 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD
  | 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_USB_BAD;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then to enable the pin&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_GPIO-&amp;gt;PIN_CNF[CFG_PIN_POWERMANAGER_FRONT_ENABLE] = pinDisconnectInputBuffer 
    | GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos 
    | GPIO_PIN_CNF_DRIVE_S0S1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos;&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt;And to disable it again&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_GPIO-&amp;gt;PIN_CNF[CFG_PIN_POWERMANAGER_FRONT_ENABLE] = pinDisconnectInputBuffer 
    | GPIO_PIN_CNF_DIR_Output &amp;lt;&amp;lt; GPIO_PIN_CNF_DIR_Pos 
    | GPIO_PIN_CNF_DRIVE_S0D1 &amp;lt;&amp;lt; GPIO_PIN_CNF_DRIVE_Pos 
    | GPIO_PIN_CNF_PULL_Pulldown &amp;lt;&amp;lt; GPIO_PIN_CNF_PULL_Pos;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452345?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 15:55:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5679e12-502c-4fc9-a6a9-c9f41144d472</guid><dc:creator>snoopy20</dc:creator><description>[deleted]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/452174?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 08:29:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb300d84-eb28-4cf6-9853-a664884bd48c</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="snoopy20"]1. turn both off using&amp;nbsp;&lt;span&gt;GPIOTE_CONFIG_MODE_Disabled&lt;/span&gt;[/quote]
&lt;p&gt;This will disable GPIOTE channel, and not really do anything with the state of the GPIO itself.&lt;/p&gt;
&lt;p&gt;This is highly likely not the functionality you&amp;#39;re after.&lt;/p&gt;
[quote user="snoopy20"]I may have a solution, if I leave GPIOTE Task enabled but instead switch GPIO to be an input with a pull-down enabled...?[/quote]
&lt;p&gt;No, but you can use more PPI channels to ensure that other GPIOTE OUT channels are set in your wanted state at that time.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you share a diagram or similar on how you want your GPIOs to be set in each COMP state?&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: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451816?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 17:17:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c84c2268-c8d1-4fe0-95af-9689275a68fc</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;I think I have it. The UVLO is triggered by the two downstream circuits controlled by these enable pins, and the circuits are bucks which turn off fast and turn on slower. With that in mind when I want to turn either on...&lt;br /&gt;&lt;br /&gt;1. turn both off using&amp;nbsp;&lt;span&gt;GPIOTE_CONFIG_MODE_Disabled&lt;br /&gt;2. the comparator will now be in high.&lt;br /&gt;3. Turn an output on using&amp;nbsp;GPIOTE_CONFIG_MODE_Task and&amp;nbsp;OUTINIT=high&lt;br /&gt;4. Turn on the other output if it were already enabled.&lt;br /&gt;&lt;br /&gt;Given the speed/delay of the buck(s) turning on the comparator event wont fire between steps 3 and 4 so all will be in sync.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451812?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 16:52:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fdde333-9b2a-4973-b9fe-d31c1f3a848b</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;I may have a solution, if I leave GPIOTE Task enabled but instead switch GPIO to be an input with a pull-down enabled...?&lt;br /&gt;&lt;br /&gt;edit: datasheet suggests not.&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_getting_started%2FUG%2Fgs%2Fdevelop_sw.html&amp;amp;cp=1_0_2"&gt;infocenter.nordicsemi.com/index.jsp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451776?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 14:49:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b30de1db-c106-429a-bb45-efbcbee41e54</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Sorry that&amp;#39;s an error (now corrected), the PPI event controls two pins, front and rear (I haven&amp;#39;t tested this revised code yet, awaiting pcb arrival this week). The event actually controls three pins, but PPI only supports the single fork so I use two channels. Also one of the channels doesn&amp;#39;t use the SET event.&lt;br /&gt;&lt;br /&gt;No, I am now using&amp;nbsp;&lt;span&gt;NRF_COMP. I managed to make a pin available, but whether it&amp;#39;s comparator or gpiote input the query remains the same. :)&lt;br /&gt;&lt;br /&gt;All that matters is:&lt;br /&gt;&lt;br /&gt;a) ensure the comparator is level high&lt;br /&gt;b) set the gpiote pin high&lt;br /&gt;c) do the above atomically - the comparator can&amp;#39;t go low between a and b.&lt;br /&gt;&lt;br /&gt;I occasionally need to override the GPIOTE output. At that point when I turn it back on it is not necessarily in sync with the comparator output. This is the problem with events rather than levels. Anyhow, it is a condition I must resolve.&lt;br /&gt;&lt;br /&gt;Simplied init:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  // gpiote
  NRF_GPIOTE-&amp;gt;CONFIG[CFG_GPIOTE_POWERMANAGER_FRONT] = GPIOTE_CONFIG_MODE_Disabled &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | CFG_PIN_POWERMANAGER_FRONT_ENABLE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;
  
  // ppi
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_UP;
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_SET[CFG_GPIOTE_POWERMANAGER_FRONT];
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_DOWN;
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[CFG_GPIOTE_POWERMANAGER_FRONT];
 
  NRF_PPI-&amp;gt;CHENSET = 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD
    | 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD;

  // UVLO
  NRF_COMP-&amp;gt;REFSEL = UVLO_REFERENCE &amp;lt;&amp;lt; COMP_REFSEL_REFSEL_Pos;
  NRF_COMP-&amp;gt;TH = UVLO_HYSTERESIS_UP &amp;lt;&amp;lt; COMP_TH_THUP_Pos | UVLO_HYSTERESIS_DOWN &amp;lt;&amp;lt; COMP_TH_THDOWN_Pos;
  NRF_COMP-&amp;gt;PSEL = COMP_UVLO &amp;lt;&amp;lt; COMP_PSEL_PSEL_Pos;
  NRF_COMP-&amp;gt;ENABLE = COMP_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; COMP_ENABLE_ENABLE_Pos;
&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Imagine you want to&amp;nbsp;override GPIOTE output, by toggling GPIOTE_CONFIG_MODE_[Disabled|Task],&amp;nbsp;and when you&amp;nbsp;choose task it must&amp;nbsp;give the same output as the current comparator state.&lt;br /&gt;&lt;br /&gt;Perhaps calling COMP.SAMPLE will fire and propagate the correct event?...&lt;/span&gt;&lt;span&gt;&lt;br /&gt;Andrew&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451770?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 14:40:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:799dc0c8-814b-41f9-aed6-42a5e8227f1e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="snoopy20"]So, for some reason I thought GPIOTE PSEL had a null, it doesn&amp;#39;t. That means I have to toggle from task to disable and vice versa sometimes, which&amp;nbsp;potentially could race with the comparator output.&lt;br /&gt;&lt;br /&gt;So when I come to set a GPIOTE output I have to:&lt;br /&gt;&lt;br /&gt;a) ensure the comparator is level high&lt;br /&gt;b) set the gpiote pin high&lt;br /&gt;c) do the above atomically - the comparator can&amp;#39;t go low between a and b.[/quote]
&lt;p&gt;Your code disables the CFG_GPIOTE_POWERMANGER_FRONT /_REAR channels, ie. these will not be used by the GPIOTE module at all. Is this intended?&lt;/p&gt;
&lt;p&gt;If you want &amp;#39;n&amp;#39; amount of&amp;nbsp;GPIOTE TASKs&amp;nbsp;to occur when EVENTS_DOWN is triggered, you should configure all your GPIOTE channels as TASK.&lt;/p&gt;
&lt;p&gt;In your PPI configuration, you seem to .FORK with the exact same TASK EP as originally set i CH[].TEP.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I highly suspect that you want the triggered GPIOTE OUT tasks to be reset in the .FORK operation? ie. if EVENTS_UP occurs, set &amp;quot;CFG_GPIOTE_POWERMANAGER_FRONT&amp;quot; and&amp;nbsp;SET &amp;quot;CFG_GPIOTE_POWERMANAGER_REAR&amp;quot; ? Vice-versa on the EVENTS_DOWN&amp;nbsp;?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="snoopy20"]However related to the original question I must ensure the GPIOTE pin always has the correct output. My understanding is if the GPIOTE is enabled as a task after the comparator is running then the PPI wont be picked up, because it&amp;#39;s not propagating continuously by clock. I may be wrong with this and it is a fundamental question.[/quote]
&lt;p&gt;It is clear to me that you&amp;#39;re using the NRF_COMP peripheral, and not a external circuit, as I initially thought. Sorry for misunderstanding.&lt;/p&gt;
&lt;p&gt;GPIOTE is related to TASK and EVENT system. It can be tied towards an event or task occurring and performing a specific GPIO related task, like SET/CLR.&lt;/p&gt;
&lt;p&gt;Please note that PPI cannot perform a logical operation, like evaluating a if/else condition.&amp;nbsp;PPI is quite simple in terms of what features can be done without CPU intervention.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That being said, it looks like you want to set a given &amp;quot;bit pattern&amp;quot; on each event on a total of 3 GPIOs. Could you share the wanted state(s) based on each EVENTS_* that occurs?&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: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451583?ContentTypeID=1</link><pubDate>Sat, 21 Oct 2023 16:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac30a7a9-f90e-42df-ac93-c67051d44093</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;So, for some reason I thought GPIOTE PSEL had a null, it doesn&amp;#39;t. That means I have to toggle from task to disable and vice versa sometimes, which&amp;nbsp;potentially could race with the comparator output.&lt;br /&gt;&lt;br /&gt;So when I come to set a GPIOTE output I have to:&lt;br /&gt;&lt;br /&gt;a) ensure the comparator is level high&lt;br /&gt;b) set the gpiote pin high&lt;br /&gt;c) do the above atomically - the comparator can&amp;#39;t go low between a and b.&lt;br /&gt;&lt;br /&gt;Some init code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  // gpiote
  NRF_GPIOTE-&amp;gt;CONFIG[CFG_GPIOTE_POWERMANAGER_USB] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | CFG_PIN_POWERMANAGER_USB_ENABLE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;
  NRF_GPIOTE-&amp;gt;CONFIG[CFG_GPIOTE_POWERMANAGER_FRONT] = GPIOTE_CONFIG_MODE_Disabled &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | CFG_PIN_POWERMANAGER_FRONT_ENABLE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;
  NRF_GPIOTE-&amp;gt;CONFIG[CFG_GPIOTE_POWERMANAGER_REAR] = GPIOTE_CONFIG_MODE_Disabled &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | CFG_PIN_POWERMANAGER_REAR_ENABLE &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos;

  // ppi
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_USB_BAD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_DOWN;
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_USB_BAD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[CFG_GPIOTE_POWERMANAGER_USB];
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_UP;
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_SET[CFG_GPIOTE_POWERMANAGER_FRONT];
  NRF_PPI-&amp;gt;FORK[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_SET[CFG_GPIOTE_POWERMANAGER_FRONT];
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].EEP = (uint32_t) &amp;amp;NRF_COMP-&amp;gt;EVENTS_DOWN;
  NRF_PPI-&amp;gt;CH[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[CFG_GPIOTE_POWERMANAGER_REAR];
  NRF_PPI-&amp;gt;FORK[CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[CFG_GPIOTE_POWERMANAGER_REAR];

  NRF_PPI-&amp;gt;CHENSET = 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_GOOD
    | 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_FRONTREAR_BAD
    | 1 &amp;lt;&amp;lt; CFG_PPI_POWERMANAGER_UVLO_USB_BAD;

  // UVLO
  NRF_COMP-&amp;gt;REFSEL = UVLO_REFERENCE &amp;lt;&amp;lt; COMP_REFSEL_REFSEL_Pos;
  NRF_COMP-&amp;gt;TH = UVLO_HYSTERESIS &amp;lt;&amp;lt; COMP_TH_THUP_Pos;
  NRF_COMP-&amp;gt;PSEL = COMP_UVLO &amp;lt;&amp;lt; COMP_PSEL_PSEL_Pos;
  NRF_COMP-&amp;gt;ENABLE = COMP_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; COMP_ENABLE_ENABLE_Pos;
  NRF_COMP-&amp;gt;TASKS_SAMPLE = COMP_TASKS_SAMPLE_TASKS_SAMPLE_Trigger &amp;lt;&amp;lt; COMP_TASKS_SAMPLE_TASKS_SAMPLE_Pos;

  // wait a moment for voltage to stablize
  // if it doesn&amp;#39;t happen watchdog will reset
  while (!NRF_COMP-&amp;gt;RESULT) {
    NRF_COMP-&amp;gt;TASKS_SAMPLE = 1;
  };
  NRF_COMP-&amp;gt;EVENTS_DOWN = 0;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451580?ContentTypeID=1</link><pubDate>Sat, 21 Oct 2023 12:40:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13d20098-a9a9-4577-9613-c67b92720626</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve resolved it a different way. The external comparator was due to all analog pins being used for ADC, but I&amp;#39;ve cleared one by means of some pin auxing and now have the built in comparator available.&lt;br /&gt;&lt;br /&gt;So without the GPIOTE pin detect I now have comparator -&amp;gt; ppi -&amp;gt; GPIOTE pin out.&lt;br /&gt;&lt;br /&gt;However related to the original question I must ensure the GPIOTE pin always has the correct output. My understanding is if the GPIOTE is enabled as a task after the comparator is running then the PPI wont be picked up, because it&amp;#39;s not propagating continuously by clock. I may be wrong with this and it is a fundamental question.&lt;br /&gt;&lt;br /&gt;Otherwise I intend to enable GPIOTE, enable the comparator, call comparator.sample (which I think will always fire one of the events? And then only disable the GPIOTE pin, but not the task, so it should be switching correctly.&lt;br /&gt;&lt;br /&gt;I have to be careful as I need to disable the pin output then reconnect it transparent to the comparator output, which must always be outbound when I reenable the pin output.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;br /&gt;&lt;br /&gt;Andrew&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451538?ContentTypeID=1</link><pubDate>Fri, 20 Oct 2023 14:40:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddca26d0-af57-4144-86a6-d363ea85f19f</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;
&lt;p&gt;With such a high input frequency, it will be problematic for the PPI/GPIOTE to be able to handle both events. This is because the propagated delay in PPI is based on the system as a whole, and one cannot guarantee that other PPI signals does not occur within the same timeframe. Also, do you require rising and falling edge detection of these two 5 MHz signals? If&amp;nbsp;yes, then it would&amp;nbsp;effectively double the frequency.&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: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451294?ContentTypeID=1</link><pubDate>Thu, 19 Oct 2023 12:07:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec401d7b-0276-4ddc-a50c-c695bfc0b42f</guid><dc:creator>snoopy20</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;LMV393 has a propagation of 0.2us, which is 5 MHz.&lt;br /&gt;&lt;br /&gt;As you say it&amp;#39;s synchronous to the 16MHz clock, so let&amp;#39;s say at max there are 5 edges at 0.2us apart. Would PPI/GPIOTE be able to keep up driving an output pin using the SET/CLEAR events?&lt;br /&gt;&lt;br /&gt;It sounds like it would, so long as the propagation didn&amp;#39;t take more than 3 clock cycles.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Level based control of GPIOTE</title><link>https://devzone.nordicsemi.com/thread/451282?ContentTypeID=1</link><pubDate>Thu, 19 Oct 2023 11:53:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70838943-f87b-49ef-b233-3950eba82c65</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=""]What I can&amp;#39;t determine from the datasheet is whether once the initial output of GPIOTE is set if PPI &amp;amp; GPIOTE are fully async to the clock in which case it would be like level control where they couldn&amp;#39;t miss an event, or whether the clock is working to determine the event (like a D gate) in which case potentially the event could be missed.[/quote]
&lt;p&gt;If I understand the scenario correct, you want two IN channels to, based on falling/rising edge-triggering, SET/CLR two other GPIOs. Please correct me if I&amp;#39;m mistaken.&lt;/p&gt;
&lt;p&gt;GPIOTE IN/OUT, when connected through PPI, will be synchronous to the internal 16 MHz peripheral clock.&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;more than one operation occurs on the same clock cycle, one event can be postponed to the next clock cycle.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is however one scenario that can occur, which is errata #155:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52810_Rev3/ERR/nRF52810/Rev3/latest/anomaly_810_155.html?cp=5_5_1_0_1_12"&gt;https://infocenter.nordicsemi.com/topic/errata_nRF52810_Rev3/ERR/nRF52810/Rev3/latest/anomaly_810_155.html?cp=5_5_1_0_1_12&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have two GPIOTE IN channels occurring within the timed scope (ie. &amp;lt; 1.3 us apart), you will hit this errata.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The side-effect of this errata workaround is higher current consumption, as the peripheral clock tree will be kept in sleep mode.&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>