How to set GPIO pin DETECT signal with NCS ?

Hi,

I'm trying to put my nRF52840 in System OFF and wake it up by DETECT signal on GPIO. For that I use gpio_pin_configure() with GPIO_INPUT | GPIO_INT_HIGH_1 flags but it doesn't work. I looked on the code sample nfc/system_off.

I guess the chip is in System OFF according to the current consumption but I can't wake up.

Here is the code used:

gpio_pin_configure(p_act, ACT_PIN, GPIO_INPUT | GPIO_INT_HIGH_1);
pm_power_state_force((struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
k_sleep(K_MSEC(1));

Is there something wrong in the procedure ? GPIO_INT_HIGH_1 and GPIO_INT_LOW_0 are the correct flags ?

Best regards,

Romain

Edit: The ACT pin is configured as output for Radio Notification and set to input just before System OFF procedure. If there is nothing wrong in the above lines I may try to disconnect mpsl IRQ from the ACT pin...

Config: SES with NCS 1.6.1, WIN10 x64

Parents
  • Hi Romain,

    I use gpio_pin_configure() with GPIO_INPUT | GPIO_INT_HIGH_1 flags but it doesn't work

    How does this fail?

    GPIO_INT_HIGH_1 and GPIO_INT_LOW_0 are the correct flags ?

    Please see the available flags in the GPIO API reference for v1.6.1. Are the flags below the ones you might be looking for? If using these flags does not help I will have a closer look at the procedure. 

    • GPIO_INT_LEVEL_LOW
      Configures GPIO interrupt to be triggered on pin physical level low and enables it.

    • GPIO_INT_LEVEL_HIGH
      Configures GPIO interrupt to be triggered on pin physical level high and enables it.

    Have you tried modifying the nfc/system_off sample as suggested in the sample's README.rst?

    Another sample to look at is the nRF5x System Off demo.

    Best regards,

    Håkon

Reply
  • Hi Romain,

    I use gpio_pin_configure() with GPIO_INPUT | GPIO_INT_HIGH_1 flags but it doesn't work

    How does this fail?

    GPIO_INT_HIGH_1 and GPIO_INT_LOW_0 are the correct flags ?

    Please see the available flags in the GPIO API reference for v1.6.1. Are the flags below the ones you might be looking for? If using these flags does not help I will have a closer look at the procedure. 

    • GPIO_INT_LEVEL_LOW
      Configures GPIO interrupt to be triggered on pin physical level low and enables it.

    • GPIO_INT_LEVEL_HIGH
      Configures GPIO interrupt to be triggered on pin physical level high and enables it.

    Have you tried modifying the nfc/system_off sample as suggested in the sample's README.rst?

    Another sample to look at is the nRF5x System Off demo.

    Best regards,

    Håkon

Children
  • Hi Håkon,

    How does this fail?

    The nRF never wakes-up (it needs POR).

    Yes I think GPIO_INT_LEVEL_LOW would be more suitable than GPIO_INT_LOW_0 alone but it still doesn't work.

    I missed the sample nRF5x System Off demo, good to know. Interesting, it uses hal/nrf_gpio with command nrf_gpio_cfg_sense_set().

    I may ask my question differently:

    What do you suggest to use DETECT signal by setting SENSE on a GPIO pin (register PIN_CNF[16,17]) when using NCS ?

    - Is it only available through nrf_gpio

    - Does it exist within GPIO API

    - Should I simply direct access PIN_CNF register

  • I have tested both variants gpio_pin_configure() and nrf_gpio_cfg_sense_input() but only the second one set the correct value in PIN_CNF[myPIN].

    But the nRF still doesn't wakeup when the pulse comes on the configured pin... The trace shows the level high pulse (~20us) and the nRF never start (LOG in SYSINIT and main don't show up...).

    My proj.conf (or autoconf.h) has CONFIG_PM=y, CONFIG_PM_DEVICE=y, CONFIG_GPIO=y, the System OFF demo works correctly on my nrf52840dk.

  • Hi Romain

    Sorry for the slow response on this case. Håkon is currently unavailable, and I will help out in the mean time. 

    Are you still having issues with this?

    If so, can you please share the current state of your code, and I will take a look at it right away. 

    Best regards
    Torbjørn

Related