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

NFC as GPIO

Hello,

I'm using the same SDK used on the Thingy:52, compiling with GCC.  I'm using the Rigado BMD-350-A which uses the nrf52832.

I'd like to use P0.09 and P0.10 as GPIO instead of NFC.  I've added CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS=1  (I've done that with and without the =1) to the makefile under CFLAGS += -DNRF52.  I've also used nRFjprog --recover .  I'm not sure if the functionality removed is the pins as GPIOs or as NFC.  The pins still aren't toggling properly as GPIO after being configured as output in the code.  What must be done to configure these two pins as GPIO?

Thanks!

Parents
  • I found a solution that worked for me.  I put this code block in the main function.  I found it here.

    /* MWU Enable -- This is workaround suggested by Aryan on the Nordic Developer Zone */
    NRF_MWU->REGIONENSET
        = ((MWU_REGIONENSET_RGN0WA_Set << MWU_REGIONENSET_RGN0WA_Pos) 
         | (MWU_REGIONENSET_PRGN0WA_Set << MWU_REGIONENSET_PRGN0WA_Pos));
    
    /* Turn on flash write enable and wait until the NVMC is ready: */
    NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos);
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
    
    /* write to the register */
    NRF_UICR->NFCPINS = 0xFFFFFFFE;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        
    /* Turn off flash write enable and wait until the NVMC is ready: */
    NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos);
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
        
    /* MWU Disable -- This is workaround suggested by Aryan on the Nordic Developer Zone */
    NRF_MWU->REGIONENCLR
        = ((MWU_REGIONENCLR_RGN0WA_Clear << MWU_REGIONENCLR_RGN0WA_Pos) 
         | (MWU_REGIONENCLR_PRGN0WA_Clear << MWU_REGIONENCLR_PRGN0WA_Pos));
                

  • The solution you propose should only be used if a bit requires changing, and not on every reset. 

    Be aware of nWRITE. The UICR register is part of the Flash memory, and it must not be repeatedly written (max 181 times) as it would be by an indiscriminate register write in user code on every reset. The Nordic SystemInit() checks the value before writing when using the defines to avoid repeated writes. This also means - for example - that the NFC pins can not be easily repeatedly switched between NFC mode and I/O port mode.

    I quote:

    "11.3 Writing to user information configuration registers (UICR)
    User information configuration registers (UICR) are written in the same way as Flash. After UICR has been written, the new UICR configuration will only take effect after a reset.
    UICR can only be written nWRITE number of times before an erase must be performed using ERASEUICR or ERASEALL."

    nWRITE,BLOCK Amount of writes allowed in a block between erase 181

Reply
  • The solution you propose should only be used if a bit requires changing, and not on every reset. 

    Be aware of nWRITE. The UICR register is part of the Flash memory, and it must not be repeatedly written (max 181 times) as it would be by an indiscriminate register write in user code on every reset. The Nordic SystemInit() checks the value before writing when using the defines to avoid repeated writes. This also means - for example - that the NFC pins can not be easily repeatedly switched between NFC mode and I/O port mode.

    I quote:

    "11.3 Writing to user information configuration registers (UICR)
    User information configuration registers (UICR) are written in the same way as Flash. After UICR has been written, the new UICR configuration will only take effect after a reset.
    UICR can only be written nWRITE number of times before an erase must be performed using ERASEUICR or ERASEALL."

    nWRITE,BLOCK Amount of writes allowed in a block between erase 181

Children
No Data
Related