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

pin change interrupt with nrf52 and s132

Hello,

I want to know what is the correct way to use GPIOTE while my softdevice is running. I have referred the example of pin_change_interrupt that is provided with SDK12.1, which runs as expected, but if I am writing that code to my main.c which has softdevice running, my device just freezes.

Also, in my current custom code, I am using app_uart as the basic reference and I am already using timer1 in main.c.

I need to add another information. I was trying to add timer2 event handler also in the code. But if i add either timer2 or gpiote event handler, my code is freezed.

Is there like a limitation on interrupts or is there any interrupt priority to be set? How do I debug this?

Edit: Relevant code lines:

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
        nrf_drv_gpiote_out_toggle(PIN_OUT);
}



static void gpio_init(void)
{
        ret_code_t err_code;

        if (!nrf_drv_gpiote_is_init())
        {
                err_code = nrf_drv_gpiote_init();
                APP_ERROR_CHECK(err_code);
        }

        nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

        err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config);
        APP_ERROR_CHECK(err_code);

        nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
        in_config.pull = NRF_GPIO_PIN_PULLUP;

        err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
        APP_ERROR_CHECK(err_code);

        nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}


int main(void)
{
        uint32_t err_code;

        // Initialize.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
        uart_init();
        bool erase_bonds;
        buttons_leds_init(&erase_bonds);
        indicators_init();
        gpio_init();
        ble_stack_init();
        gap_params_init();
        services_init();
        advertising_init();
        conn_params_init();

        err_code = nrf_drv_rng_init(NULL);
        APP_ERROR_CHECK(err_code);
        printf("\r\nUART Start!\r\n");
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);

        for (;; )
        {
                power_manage();
        }
}

Edit: If I keep the input pin grounded, the BLE activity is stopped, If the input pin is pulled up BLE activity resumes. I am aware the gpio event handler will be called if the input pin toggles state. But the output pin never glows. Input pin is P0.21.

Parents Reply Children
No Data
Related