This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NCS: How to configure gpio input pins?

Dear NCS experts,
 
can you please lend a hand at configuring gpio input pins at nRF Connect SDK (1.7.1)? Here's a short code snippet that configures pin 3 as input:
 


 
This is basically working. When pushing or releasing the button wired to pin 3 button_callback() is executed. Strange thing, however, is that gpio_pin_get() always returns 1, even if the button is released. In which case I'd expect the returned value to be zero. Do you have any ideas how to fix this?

And second:

Another thing that causes problems is setting BUTTON_PIN to 5 in the above example, which causes the call of gpio_pin_get(gpiodev, pin) at button_callback() to assert with:
ASSERTION FAIL [(cfg->port_pin_mask & (gpio_port_pins_t)(1UL << (pin))) != 0U] @ WEST_TOPDIR/zephyr/include/drivers/gpio.h:1107
        Unsupported pin
[00:00:45.254,425] <err> os: r0/a1:  0x00000004  r1/a2:  0x00000453  r2/a3:  0x00000003
[00:00:45.254,425] <err> os: r3/a4:  0x200023c0 r12/ip:  0x00000000 r14/lr:  0x0001ae11
[00:00:45.254,425] <err> os:  xpsr:  0x41000016
[00:00:45.254,455] <err> os: Faulting instruction address (r15/pc): 0x000424aa
[00:00:45.254,455] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:00:45.254,455] <err> os: Fault during interrupt handling
 
[00:00:45.254,486] <err> os: Current thread: 0x20002f50 (idle 00)
[00:00:45.535,369] <err> fatal_error: Resetting system
 
Question here is, why is pin 5 unsupported? And how can it be made "supported"?  

The hardware is based on a nRF52832 and is working well with a firmware application based on the Mesh SDK, so, obviously, I'm missing some important NCS details here.

Your help is very much appreciated,
Thank you,
Michael.