<?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>Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53378/pin-interrupt-triggered-without-transitioning-from-hi-to-low</link><description>I am using an ADC where the SPI MISO pin also acts as a data ready pin when it transitions from Hi-to-Low as detailed in the link below. I am able to configure this and it works as intended when I configure the pin to be high accuracy NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Oct 2019 11:03:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53378/pin-interrupt-triggered-without-transitioning-from-hi-to-low" /><item><title>RE: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/216577?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2019 11:03:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e95f098e-8685-4f1e-92b5-562909c99901</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;You are doing quite a lot of processing and log printing in this handler, so if you&amp;#39;re waking up every 1.3 ms, the log printing alone will account for quite some time.&lt;/p&gt;
&lt;p&gt;Try toggling a pin inside the handler, and for debugging purposes; keep the function small, and see how often it toggles using a logic analyzer / oscilloscope.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/216444?ContentTypeID=1</link><pubDate>Wed, 23 Oct 2019 16:32:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4b63a99-a158-459d-85ef-4b9f93d87d6f</guid><dc:creator>Wael</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/hkn"&gt;H&amp;aring;kon&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I did and it works. but I do not see any current difference between the high and low accuracy. you can see from the plot below the cpu never goes to sleep. the interrupt handler gets triggered very 1.3 ms. the average current for bothe low and high accuracy look the same.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1571848128805v1.png" alt=" " /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
this is what I do in my init_gpio function

    nrfx_gpiote_in_config_t adc_drdy_pin_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
    NRFX_IRQ_DISABLE(GPIOTE_IRQn); // disable the GPIOTE IRQs
    //nrfx_gpiote_in_uninit(SPI_MISO_PIN); // uninit this pin, else we get error
    adc_drdy_pin_config.pull = NRF_GPIO_PIN_PULLUP;
    err_code = nrf_drv_gpiote_in_init(SPI_MISO_PIN, &amp;amp;adc_drdy_pin_config, adc_drdy_interrupt_handler);
    APP_ERROR_CHECK(err_code);
    nrfx_gpiote_in_event_enable(SPI_MISO_PIN, false);
    nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_PORT); // clear the spontanious interrupt that was triggered from calling nrfx_gpiote_in_event_enable()
    NRFX_IRQ_ENABLE(GPIOTE_IRQn); // enable the GPIOTE IRQs	
    
    
this is my interrupt handler

static void adc_drdy_interrupt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    uint32_t       sensor_data = 0;
    uint32_t       dStatus = 0;
    uint32_t       dCRC = 0;
    uint32_t       cCRC = 0;
    ret_code_t     err_code = 0;
  
    NRF_LOG_INFO(&amp;quot;Interrupt Counter = %d\n&amp;quot;, app_timer_cnt_get());
    nrfx_gpiote_in_event_enable(SPI_MISO_PIN, false);
    nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_PORT); // clear the spontanious interrupt that was triggered from calling nrfx_gpiote_in_event_enable()      
    CRITICAL_REGION_ENTER();
    sensor_data = dataRead(&amp;amp;dStatus, &amp;amp;dCRC);
    cCRC = compute_adc_crc8(sensor_data, dStatus);
  
    if(cCRC != dCRC)
    {
        NRF_LOG_INFO(&amp;quot;Received CRC does NOT match calculated CRC! S%d, ADC DATA = 0x%X, recCRC = 0x%X, cCRC = 0x%X, Status = 0x%X&amp;quot;, m_adc_sensor_number, sensor_data, dCRC, cCRC, dStatus);
        return;
    }
    
    CRITICAL_REGION_EXIT();  
    
    NRF_LOG_INFO(&amp;quot;S%d ADC DATA = 0x%X\n&amp;quot;, m_adc_sensor_number, sensor_data);
    switch(m_adc_sensor_number)
    {
      case 1:
        registers[INPMUX_ADDR_MASK]= ADS_P_AIN2 | ADS_N_AIN3;     // S2  
        regWrite(INPMUX_ADDR_MASK, registers[INPMUX_ADDR_MASK]);
      
        read_strain_gauge_data_result[0] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);
        read_strain_gauge_data_result[1] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
        read_strain_gauge_data_result[2] = (uint8_t)(sensor_data &amp;amp; 0xFF);      
        m_adc_sensor_number++;
        break;
      case 2:
        registers[INPMUX_ADDR_MASK]= ADS_P_AIN4 | ADS_N_AIN5;     // S3
        regWrite(INPMUX_ADDR_MASK, registers[INPMUX_ADDR_MASK]);
      
        read_strain_gauge_data_result[3] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);
        read_strain_gauge_data_result[4] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
        read_strain_gauge_data_result[5] = (uint8_t)(sensor_data &amp;amp; 0xFF);
        m_adc_sensor_number++;
        break;
      case 3:
        registers[INPMUX_ADDR_MASK]= ADS_P_AIN6 | ADS_N_AIN7;   // S4
        regWrite(INPMUX_ADDR_MASK, registers[INPMUX_ADDR_MASK]);
      
        read_strain_gauge_data_result[6] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);
        read_strain_gauge_data_result[7] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
        read_strain_gauge_data_result[8] = (uint8_t)(sensor_data &amp;amp; 0xFF);
        m_adc_sensor_number++;
        break;
      case 4:
        registers[INPMUX_ADDR_MASK]= ADS_P_AIN8 | ADS_N_AIN9;   // S5
        regWrite(INPMUX_ADDR_MASK, registers[INPMUX_ADDR_MASK]);
      
        read_strain_gauge_data_result[9] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);
        read_strain_gauge_data_result[10] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
        read_strain_gauge_data_result[11] = (uint8_t)(sensor_data &amp;amp; 0xFF);
        m_adc_sensor_number++;
        break;
      case 5:
        registers[INPMUX_ADDR_MASK]= ADS_P_AIN10 | ADS_N_AIN11; // S6
        regWrite(INPMUX_ADDR_MASK, registers[INPMUX_ADDR_MASK]);
      
        read_strain_gauge_data_result[12] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);
        read_strain_gauge_data_result[13] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
        read_strain_gauge_data_result[14] = (uint8_t)(sensor_data &amp;amp; 0xFF);
        m_adc_sensor_number++;
        break;
      case 6:
        registers[INPMUX_ADDR_MASK]= ADS_P_AIN0 | ADS_N_AIN1; // S1
        regWrite(INPMUX_ADDR_MASK, registers[INPMUX_ADDR_MASK]);
      
        read_strain_gauge_data_result[15] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 16) &amp;amp; 0xFF);
        read_strain_gauge_data_result[16] = (uint8_t)((sensor_data &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
        read_strain_gauge_data_result[17] = (uint8_t)(sensor_data &amp;amp; 0xFF);
        m_adc_sensor_number = 1;
        break;
      default:
        NRF_LOG_ERROR(&amp;quot;Unknown Sensor number! Sensor Number = %d\n.&amp;quot;, device_operating_second_count);
        break;
    } 
    nrfx_gpiote_in_event_enable(SPI_MISO_PIN, true);
    nrf_gpiote_event_clear(NRF_GPIOTE_EVENTS_PORT); // clear the spontanious interrupt that was triggered from calling nrfx_gpiote_in_event_enable()
    
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/215937?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2019 12:57:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf4f40ed-cf20-41c3-8331-163ee3cdf8e1</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>[quote user="whazin"]also, how can I make sure they are on different&amp;nbsp;&lt;span&gt;GPIOTE_IN&amp;nbsp;channels?&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;For the PORT event (high_accuracy = false), there&amp;#39;s no dedicated channel. All pins, configured with SENSE, will generate a EVENTS_PORT.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/215936?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2019 12:55:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cda7f705-2505-4583-8641-3f67fb38adc4</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="whazin"]calling nrfx_gpiote_in_event_enable always seem to trigger the PORT event, even when it was already handled before. this does not make any sense. Does the&amp;nbsp;nrfx_gpiote_in_event_enable&amp;nbsp;function suppose to trigger the interrupt handler when the pin is configured for a high-to-low transition? the pin is low when the handler is triggered and never transitioned from high-to-low. I tried using the NRF_GPIO_PIN_PULLUP which does nothing since the ADC is keeping the pin low until it is configured and operating. Are there any configurations I am missing in the sdk_config file to setup the port event? this issue is killing our device power so please any help is greatly appreciated.[/quote]
&lt;p&gt;&amp;nbsp;When you are reconfiguring, did you try the workaround as posted in the thread you linked to? Ie: clearing the event, then enabling it.&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: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/215758?ContentTypeID=1</link><pubDate>Fri, 18 Oct 2019 17:11:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:734a09c9-8778-4ba9-9803-914075f91695</guid><dc:creator>Wael</dc:creator><description>&lt;p&gt;also, how can I make sure they are on different&amp;nbsp;&lt;span&gt;GPIOTE_IN&amp;nbsp;channels?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/215747?ContentTypeID=1</link><pubDate>Fri, 18 Oct 2019 14:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebff72b8-f75f-4a2a-b2b4-8be52149d9d9</guid><dc:creator>Wael</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/hkn"&gt;H&amp;aring;kon&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the reply! yes, I am assigning the same pin to both the MISO and ADC interrupt GPIO. This works when using high accuracy and according to the above link, the SPI driver takes over the pin when needed which I can confirm since the it works. I also disable the event in the interrupt handler with&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrfx_gpiote_in_event_enable(SPI_MISO_PIN, false);&lt;/p&gt;
&lt;p&gt;prior to executing any SPI transactions.&lt;/p&gt;
&lt;p&gt;moreover, when NOT using high accuracy,&amp;nbsp; the handler is getting triggered before I even configure my SPI pins. according to this link,&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39768/port-event-interupt-while-sensed-pin-is-active/156280#156280"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/39768/port-event-interupt-while-sensed-pin-is-active/156280#156280&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;calling nrfx_gpiote_in_event_enable always seem to trigger the PORT event, even when it was already handled before. this does not make any sense. Does the&amp;nbsp;nrfx_gpiote_in_event_enable&amp;nbsp;function suppose to trigger the interrupt handler when the pin is configured for a high-to-low transition? the pin is low when the handler is triggered and never transitioned from high-to-low. I tried using the NRF_GPIO_PIN_PULLUP which does nothing since the ADC is keeping the pin low until it is configured and operating. Are there any configurations I am missing in the sdk_config file to setup the port event? this issue is killing our device power so please any help is greatly appreciated.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/215689?ContentTypeID=1</link><pubDate>Fri, 18 Oct 2019 11:28:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db0d1779-57f9-4d69-b7c6-a17d0fd29b64</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;Are you assigning the same GPIO to be MISO, and GPIOTE_IN channel? That would be a pin conflict if both SPIM and GPIOTE is enabled at the same time.&lt;/p&gt;
&lt;p&gt;Is the pin floating externally? Your current configuration does not enable any pull-resistor, so if there&amp;#39;s nothing external to pull the pin to a defined level, the event is very likely to occur.&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: Pin interrupt triggered without transitioning from HI-to-LOW</title><link>https://devzone.nordicsemi.com/thread/215584?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2019 16:23:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8d1d441-4ea2-4eff-ab3a-6a081b9eee26</guid><dc:creator>Wael</dc:creator><description>&lt;p&gt;also, the interrupt handler shows that its the MISO pin that is triggering the event. Note, I do not execute any SPI read/write functions up to this point.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>