nrf52 stacked in a reset loop after setting NFCPINS as GPIO

Hi, I'm having some trouble with a custom board based on nRF52832.

I need to use NFCPINS (P0.10 and P0.9) as GPIOs.  As IDE I'm using Keil uVision. 

The code works weel till I set PIN10 as Output. If i comment it the device doesn't reset.

If I use one of the following, the microcontroller goes in a reset loop.

First attempt:

const uint32_t UICR_ADDR_0x20C __attribute__((at(0x1000120C))) __attribute__((used)) = 0xFFFFFFFE;

int main(){

    nrf_gpio_cfg_output(27); // P0.27 Connected to a LED
    
    
    nrf_gpio_cfg_output(10); // If I comment this the device doesn't reset
    
    while(1){
	}

	}

Second Attempt:

int main(){
	
	if (NRF_UICR->NFCPINS==0xFFFFFFFF){
		NRF_NVMC->CONFIG = 0x1UL; 
        while(!NRF_NVMC->READY){}
		NRF_UICR->NFCPINS = 0xFFFFFFFE;
		NRF_NVMC->CONFIG = 0x0UL;
		while(!NRF_NVMC->READY){};
	}
	
	nrf_gpio_cfg_output(27);
	
	nrf_gpio_cfg_output(10); //If i comment this the device doesn't reset
	
	while(1){

	}
   
}

Third Attempt:

How can I solve this problem?

Have a great day.

Related