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

please why nrf52832 gpio does not produce Interrupt

Here is my program:

#define EXIT_PIN       31

void EXIT_Init(void)
{

nrf_gpio_cfg_input(EXIT_PIN,GPIO_PIN_CNF_PULL_Pullup);


NVIC_EnableIRQ(GPIOTE_IRQn);

NRF_GPIOTE->CONFIG[0] = (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)
| (EXIT_PIN << GPIOTE_CONFIG_PSEL_Pos)
| (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);

NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_IN0_Set << GPIOTE_INTENSET_IN0_Pos;// ʹÄÜÖжÏÀàÐÍ:
}


void GPIOTE_IRQHandler(void)
{

    if ((NRF_GPIOTE->EVENTS_IN[0] == 1) && (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_IN0_Msk))
    {
         NRF_GPIOTE->EVENTS_IN[0] = 0;

    }

}

but  Program cannot enter interrupt,i Looking at it with an oscilloscope, there is no low level。but i use Query ,Looking at it with an oscilloscope, there is have low level. it works ok.

EXIT_PIN   is the pin which if data is ok ,Another device Pulls EXIT_PIN's level down.

Thanks very much.

  • i  changed in the  #include "nrfx_irqs_nrf52832.h",  because Symbol GPIOTE_IRQHandler multiply defined (by exit.o and nrfx_gpiote.o).

    #include "nrfx_irqs_nrf52832.h"

    // GPIOTE_IRQn
    //#define nrfx_gpiote_irq_handler GPIOTE_IRQHandler

  • sorry I described it wrong

    Program cannot enter interrupt,i Looking at it with an oscilloscope,  the EXIT_PIN Has become  low level,but cannot enter interrupt

    EXIT_PIN   is the pin which if data is ok ,Another device Pulls EXIT_PIN's level down.

    Thanks very much.

  • Can you try to base your code using the gpiote driver?
    \nRF5_SDK\examples\peripheral\pin_change_int

    For low power use:

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); // use false for low power.

    If you want several pins to interrupt you need to increment GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS in sdk_config.h

    Best regards,
    Kenneth

  • Thank you very much:

         i find out why,  the function buttons_leds_init(&erase_bonds) which has a pin which same as EXIT_PIN ,i don't use this function ,Program cannot enter interrupt.

    now,i have a problem,My interrupt configuration,

    NRF_GPIOTE->CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)

                                               | (EXIT_PIN << GPIOTE_CONFIG_PSEL_Pos) 

                                             | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);

    that Equivalent to  NRF_GPIOTE->CONFIG[0] =0x00031f01,if i use the pa_assist(PA_TXEN, PA_RXEN_NONE);

    this function changed my interrupt configuration to NRF_GPIOTE->CONFIG[0] =0x0;when pa_assist(PA_TXEN, PA_RXEN_NONE) wroks  NRF_GPIOTE->CONFIG[0] =0x31103, I just according 0x31103 find what it relation the pa_assist,so i don't use pa_assist(PA_TXEN, PA_RXEN_NONE), it works ok.

          so if i use pa_assist,my interrupt configuration is Invalid,you know why?

    the below is my function,  PA_TXEN  is 17, EXIT_PIN   is 31

    void pa_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
    {
    ret_code_t err_code;
    static const uint32_t gpio_toggle_ch = 0;
    static const uint32_t ppi_set_ch = 0;
    static const uint32_t ppi_clr_ch = 1;
    // Configure SoftDevice PA assist
    ble_opt_t opt;
    memset(&opt, 0, sizeof(ble_opt_t));
    // Common PA config
    opt.common_opt.pa_lna.gpiote_ch_id = gpio_toggle_ch; // GPIOTE channel
    opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_set_ch; // PPI channel for pin clearing
    opt.common_opt.pa_lna.ppi_ch_id_set = ppi_clr_ch; // PPI channel for pin setting
    // PA config
    opt.common_opt.pa_lna.pa_cfg.active_high = 1; // Set the pin to be active high
    opt.common_opt.pa_lna.pa_cfg.enable = 1; // Enable toggling
    opt.common_opt.pa_lna.pa_cfg.gpio_pin = gpio_pa_pin; // The GPIO pin to toggle

    // opt.common_opt.pa_lna.lna_cfg.active_high = 1;
    // opt.common_opt.pa_lna.lna_cfg.enable = 1;
    // opt.common_opt.pa_lna.lna_cfg.gpio_pin = gpio_lna_pin;
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
    APP_ERROR_CHECK(err_code);
    }

    my english is not good.

    Thank you very much

  • Thank you very much:

         i find out why,  the function buttons_leds_init(&erase_bonds) which has a pin which same as EXIT_PIN ,i don't use this function ,Program can enter interrupt.

    now,i have a problem,My interrupt configuration,

    NRF_GPIOTE->CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)

                                               | (EXIT_PIN << GPIOTE_CONFIG_PSEL_Pos) 

                                             | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);

    that Equivalent to  NRF_GPIOTE->CONFIG[0] =0x00031f01,if i use the pa_assist(PA_TXEN, PA_RXEN_NONE);

    this function changed my interrupt configuration to NRF_GPIOTE->CONFIG[0] =0x0;when pa_assist(PA_TXEN, PA_RXEN_NONE) wroks  NRF_GPIOTE->CONFIG[0] =0x31103, I just according 0x31103 find what it relation the pa_assist,so i don't use pa_assist(PA_TXEN, PA_RXEN_NONE), it works ok.

          so if i use pa_assist,my interrupt configuration is Invalid,you know why?

    the below is my function,  PA_TXEN  is 17, EXIT_PIN   is 31

    void pa_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
    {
    ret_code_t err_code;
    static const uint32_t gpio_toggle_ch = 0;
    static const uint32_t ppi_set_ch = 0;
    static const uint32_t ppi_clr_ch = 1;
    // Configure SoftDevice PA assist
    ble_opt_t opt;
    memset(&opt, 0, sizeof(ble_opt_t));
    // Common PA config
    opt.common_opt.pa_lna.gpiote_ch_id = gpio_toggle_ch; // GPIOTE channel
    opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_set_ch; // PPI channel for pin clearing
    opt.common_opt.pa_lna.ppi_ch_id_set = ppi_clr_ch; // PPI channel for pin setting
    // PA config
    opt.common_opt.pa_lna.pa_cfg.active_high = 1; // Set the pin to be active high
    opt.common_opt.pa_lna.pa_cfg.enable = 1; // Enable toggling
    opt.common_opt.pa_lna.pa_cfg.gpio_pin = gpio_pa_pin; // The GPIO pin to toggle

    // opt.common_opt.pa_lna.lna_cfg.active_high = 1;
    // opt.common_opt.pa_lna.lna_cfg.enable = 1;
    // opt.common_opt.pa_lna.lna_cfg.gpio_pin = gpio_lna_pin;
    err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
    APP_ERROR_CHECK(err_code);
    }

    my english is not good.

    Thank you very much

Related