Hi all,
I am developing an application for a custom board using the nRF52840. I need to use the reset pin (P0.18) as a regular GPIO, configured as an input with an associated interrupt. However, I am unable to set this pin as a GPIO. The steps I have followed are based on this thread.
My setup:
- First, I try to run the application on nRF52840dk
- I am using the Visual Studio nRF Connect extension, with version v2.3.0 for both toolchain and SDK to build the application.
- I flash the board using the following commands on a powershell terminal
nrfjprog -e west flash --softreset
Code configuration:
- I added CONFIG_GPIO_AS_PINRESET=n on prj.conf file
- Then, I added the following code before configuring the pin to turn on the disconnect flag on the PSELRESET registers
#ifdef CONFIG_GPIO_AS_PINRESET
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Disconnected << UICR_PSELRESET_CONNECT_Pos)) ||
((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Disconnected << UICR_PSELRESET_CONNECT_Pos))){
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->PSELRESET[0] = 18 | (1 << 31);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_UICR->PSELRESET[1] = 18 | (1 << 31);
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
// UICR changes require a reset to be effective
NVIC_SystemReset();
}
#endif
Results:
After setting these configurations, I get CONFIG_GPIO_AS_PINRESET is not set after building the application, and I get a HARD FAULT debug event when the pin configuration is set.
How can I solve this problem?
Candela