CONFIG_NFCT_PINS_AS_GPIOS=y doesn't work

Hi,

I'm using an ISP2053 (nrf5340) chip on a custom board and debugging using the nrf5340dk. I'd like to use P0.02, P0.03 as part of an SPI bus.

I set up a simple experiment where I set `CONFIG_NFCT_PINS_AS_GPIOS=y` in my prj.conf and some code to toggle various pins that I can read on my board. P0.02 and P0.03 are always 0V and other pins toggle between 0V and 3V.

I believe the NFCPINS UICR register (0x00FF8028) should read 0xFFFFFFFE but using nrfjprog I can see that the register reads 0xFFFFFFFF:

```

nrfjprog --memrd 0x00FF8028
0x00FF8028: FFFFFFFF |....|

```

After I flash the code using nrfconnect vscode, I can set the register to 0xFFFFFFFE:
```

nrfjprog --memwr 0x00FF8028 --val 0xFFFFFFFE
Parsing parameters.
Writing.

nrfjprog --memrd 0x00FF8028
0x00FF8028: FFFFFFFE |....|
```

Now the NFC GPIO pins toggle on and off like the other pins.
Is this intended? It seems like CONFIG_NFCT_PINS_AS_GPIOS=y doesn't change the register value. I can see in Guiconfig, the `NFCT pins as GPIO` option is selected. Other options in prj.conf work.
I'd prefer not have to run `nrfjprog --memwr 0x00FF8028 --val 0xFFFFFFFE` when flashing. How do I diagnose the problem further?
I'm using ncs v2.1.1.
Parents Reply Children
  • Please open a new ticket and include information about your setup, such as whether you are using a Nordic development kit or a custom board, what chip variant, and describe how you are attempting to configure the pin.

  • I just ran into a similar issue, where simple GPIO toggling of the NFC P0.03 was not working despite having CONFIG_NFCT_PINS_AS_GPIOS=y and seeing it being properly implemented in the UICR registers.

    After a bit of debugging I found that the initialization of the GPIO was occurring within a SYS_INIT call, and calling the initialization function from main instead, would allow it to work fine.

    Other non-nfc gpios called within that SYS_INIT worked fine, so it seems to only conflict with the NFC gpio configuration for some reason.

    Hopefully this helps

  • I'm not sure where SYS_INIT is. Could you please say how you solved this?

  • Found something important not covered in any of the tickets I've seen on this:

    1. CONFIG_NFCT_PINS_AS_GPIOS=y is required

    2. Power cycling the board (as opposed to simply resetting it after a firmware update) was necessary to change the NFC pin state.

    It's not clear to me if there's a different route to making the NFC peripheral transition modes without requiring a power cycle, but this was sufficient to correct the issue.

    To Nico7's question, SYS_INIT is a macro from include/zephyr/init.h that allows initialization code to run before main.  It's important to know where it's being used in modules since an error in a SYS_INIT registered function can be hard to debug otherwise.

Related