This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why does NRF_GPIO->IN always report the same sense level?

I am using app_gpiote_user_register() and ads_interrupt_enable() to define a ping change interrupt. When the code runs, I can see on my logic analyzer that the GPIO pin assigned to the interrupt is being toggled bt the external source and the GPIOTE_IRQHandler() interrupt handler is called but, the interrupt handler I assigned for that pin does not get called and what I noticed is that the sense_level set by NRF_GPIO->IN is always the same value, so no transition is detected. I added an array to capture the sense_level in the GPIOTE_IRQHandler() and after 100 iterations the values in the array are all the same. What I'm wondering is if the external pulse on the GPIO pin is too short, measured on my logic analyzer it is ~750 usecs. That seems like a long enough duration for the GPIOTE_IRQHandler() to be called and the sense_level to be read. I have no other interrupts enabled.

  • Hi,

    Could you attach your source code so we can have a look?

    BR Håkon

  • You don't supply a lot of details, but as far as I can see, this works as it's supposed to when I test it. I've attached a quick example I made earlier today, that seems to function as expected. Do you have problems with this as well?

    multiple_port_events.zip

  • I have very similar situation. I am using S110 soft devise for BT4, and the soft device is running. Then I have configured my PCA10001 (with nRF51822) board to use Button1 as input with pull-up enabled and toggle LED1 when I push or release the button. I use app_gpiote module to receive the event for toggling the LED (and not app_button). There is 2 situations that I separate:

    1. the device is sleeping, and
    2. the device has been woken up

    In the situation when the device is woken up, if I press the button I will get the LED state change and when I release the button I will get the LED release change. I use no delay timers for input filtering and the LED reaction is very fast.

    In the situation when the device is sleeping, if I press the button- nothing happens. I can keep the button down for several seconds without LED to change its state. If I now release the button, then the LED does change state.

    In the situation when the device is sleeping. if I do ~0.1 second click on the button, there will be no LED state change and the device will be woken up. On next click on the button within ~10seconds will make the LED state flicker too.

    To get the device to sleep I will wait ~20 seconds and I have no Bluetooth activity.

    I need the very first input state change event when the device is sleeping. Please advice !

  • I'm having a little trouble understanding exactly what is your question or problem. It is however important to understand that the behavior with regard to the PORT event is somewhat different when in system off and in system on.

    In system off, any change of a pin to the level defined in PIN_CNF.SENSE will cause a wakeup, but it will not cause the GPIOTE_IRQHandler to be called. However, as long as the chip is in system on, any change to a pin to the level defined in PIN_CNF.SENSE will cause the IRQ handler to run. The IRQ handler in app_gpiote will toggle the SENSE field when it runs, to make sure that it catches both edges of the signal.

    It may sound as if this difference explains the behavior you see, which sounds as if it depends on sleep level. To get similar behavior in both cases, I'd either recommend you to just not use system off (will give somewhat higher sleep current), or if you want to keep using system off, make sure to check all pin states on bootup, to see if you manually need to call some handling function.

    For further information on the sleep states of the nRF51 series, you should refer to this question: https://devzone.nordicsemi.com/index.php/what-is-the-power-and-clock-model-of-peripheral-in-nrf51

    If this doesn't help you, I'd be happy if you could post this as a separate question, focusing especially on what you don't understand, preferably with a code example. If you can't share code here, you can also create a regular support case and share code and details there.

  • Thanks. I've found where the system off happens and this is my case. The sample code from where I started will set system off when there is no connection made during the 20 seconds of time.

Related