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

Can't configure 2 gpio pins with opposite pull state

Hi,

I try configure 2 gpio pins with opposite pull state, one NRF_GPIO_PIN_PULLUP, other NRF_GPIO_PIN_PULLDOWN:

nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
in_config.pull = NRF_GPIO_PIN_PULLUP; 
err_code = nrf_drv_gpiote_in_init(PIN_BUTTON, &in_config, button_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(PIN_BUTTON, true);

nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
in_config.pull = NRF_GPIO_PIN_PULLDOWN;
err_code = nrf_drv_gpiote_in_init(PIN_IMPULSE, &in_config, impulse_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(PIN_IMPULSE, true);

But, callback don`t called.

If I configure with same pull state, then callback is called.

Why is this occurs? How to set up pins with diffrent pull state?

Thank you!

Parents
  • Hello,

    That sounds strange.
    Could you detail your issue some more: 

    But, callback don`t called.

    How are you testing this, and how does it behave differently than expected? I just want to make sure that I have understood you correctly.
    Could you also share the callback code, which is / is not being called?

    Why is this occurs? How to set up pins with diffrent pull state?

    Which pins on the nRF52832 are you using, and what are they connected to?
    Are you working with a nRF52 DK, or a custom board?

    Looking forward to resolving this issue together!

    Best regards,
    Karl 

  • In same time, I can use this code:

        nrf_gpio_cfg_input(PIN_BUTTON, NRF_GPIO_PIN_PULLUP);
    
        nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
        in_config.pull = NRF_GPIO_PIN_PULLDOWN;
        err_code = nrf_drv_gpiote_in_init(PIN_IMPULSE, &in_config, impulse_handler);
        APP_ERROR_CHECK(err_code);
        nrf_drv_gpiote_in_event_enable(PIN_IMPULSE, true);

    And then use nrf_gpio_pin_read(PIN_BUTTON)

    But that doesn't suit me..

  • Hello again,

    Could you also try to use GPIOTE_CONFIG_IN_SENSE_TOGGLE() instead of _LOTOHI for your buttons?

    I believe that if a port event is triggered on a low to high transition on a pin, a new port event can’t be triggered before that pin has gone low again or the pin is configured to sense low (which will trigger a new event on high to low transition). See the answers to this and this post.

    The results of this test will also tell us more about what might be causing the unexpected behavior you are seeing.

    Best regards,
    Karl

  • Hello! I`m very sorry for my late reply. I was on vacation.

    So, what you are saying is that both GPIOs in questions are connected with a button, sensing a change in the level, correct?

    Yes

    What was the results of these trails, were you able to confirm the callback behavior using the LED?

    Yes, the LED state did not change

    Which SoC version and variant are you working with?

    NRF52832_xxAA_REV2, SoftDevice S132 v5.0.0

    Could you also try to use GPIOTE_CONFIG_IN_SENSE_TOGGLE() instead of _LOTOHI for your buttons?

    I tried. And it works! Code:

    {    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
        in_config.pull = NRF_GPIO_PIN_PULLUP;
        err_code = nrf_drv_gpiote_in_init(PIN_BUTTON, &in_config, button_handler);
        APP_ERROR_CHECK(err_code);
        nrf_drv_gpiote_in_event_enable(PIN_BUTTON, true);}/**/
    
    
        nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);
        in_config.pull = NRF_GPIO_PIN_PULLDOWN;
        err_code = nrf_drv_gpiote_in_init(PIN_IMPULSE, &in_config, impulse_handler);
        APP_ERROR_CHECK(err_code);
        nrf_drv_gpiote_in_event_enable(PIN_IMPULSE, true);
    

    I use GPIOTE_CONFIG_IN_SENSE_TOGGLE only for one button and now... works both buttons..

    Could you share with me a stripped down project in which you are seeing this behavior?
    I will then attempt to replicate the behavior on my end, so that I may better debug it.

    For reproduce issue, just use code from my first message. And connect one button to "+" and other to "-"

  • Hello,

    Serhio said:
    I`m very sorry for my late reply. I was on vacation.

    No worries at all, I hope you had a great vacation!

    Serhio said:
    NRF52832_xxAA_REV2, SoftDevice S132 v5.0.0

    Thank you for letting me know.

    Serhio said:
    I tried. And it works!
    Serhio said:
    I use GPIOTE_CONFIG_IN_SENSE_TOGGLE only for one button and now... works both buttons..

    I am glad to hear that! Then I would think the problem was caused due to the PORT event already being generated when the second one came in.
    Is the application now working as you had intended?
    If you are using TOGGLE on both, you can keep track of which direction it has transitioned since the last event.

    Best regards,
    Karl 

  • Is the application now working as you had intended?

    Yes, Karl, I'm satisfied how the application works now. Thank you for your help.

  • Great, I am happy to hear that the application now works as intended! 

    Serhio said:
    Thank you for your help.

    It is no problem at all, Serhio! I am happy to help.

    Please do not hesitate to open a new ticket if you should encounter any issues or questions in the future.

    Best regards,
    Karl

Reply Children
No Data
Related