Interrupts on GPIO Pin

Hi,
We are currently attempting to migrate our nrf5 SDK code to NCS, on a custom board based on nrf52833.

We have an accelerometer on the device with configurable interrupt pins, and we know they are configured correctly because if we read the relevant interrupt register, we can see when a movement happens or not.

However - we have been unable as of yet to get the interrupt to trigger on the MUC level.

This is our code currently - note that I have tried several different flags of GPIO_INT_* on gio_pin_interrupt_configure_dt, as well as adding to gpio_pin_configure_dt:

const struct gpio_dt_spec int1_spec = {
.dt_flags = GPIO_ACTIVE_HIGH,
.pin = 10,
.port = DEVICE_DT_GET(DT_NODELABEL(gpio0))
}; 

bool init_acc_gpio_and_int(void)
{
    int err = gpio_pin_configure_dt(&int1_spec, GPIO_ACTIVE_HIGH | GPIO_INPUT);
    if(err){
        printk("int1 input init failed (%d)\n",err);
        return false;
    }

    printk("Pin is %u\n",int1_spec.pin);

    err = gpio_pin_interrupt_configure_dt(&int1_spec, GPIO_INT_EDGE_RISING);
    if(err){
        printk("int1 interrupt init failed (%d)\n",err);
        return false;
    }

    printk("Pin is %u\n",int1_spec.pin);

    gpio_init_callback(&cb,int_cb,BIT(int1_spec.pin));
    err = gpio_add_callback(int1_spec.port,&cb);
    if(err){
        printk("Failed to add int1 callback (%d)\n",err);
        return false;
    }
    return true;
}

Is this the correct mode of operation? Do I need to add something to the devicetree (.dts) for this to work?
Thanks!
Roi

Parents Reply
  • Glad to hear. 

    By default, the NFC pins, P0.09 and P0.10 are not working as normal GPIOs, because they are reserved for the NFC peripheral. However, it is possible to use them as normal GPIOs, but it requires that config to be enabled. It is a common pitfall. At least if you are using custom boards. It is printed on the back of the DKs that these are not routed out to the headers, and that makes people start looking for how to do that, but if you don't see the print, it just looks like the pin is not working.

    Best regards,

    Edvin

Children
Related