Hello,
I just wanted to share a problem I encountered and make some suggestions :
I lost some time looking for a TWI problem while it was actually related to the pin reset configuration. After flashing a test firmware which had the CONFIG_GPIO_AS_PINRESET flag defined, I flashed another code which hadn't defined the flag and was using the reset pin as SCL for TWI, so it didn't work.
Given the pin reset configuration is done by PSELRESET registers in the UICR section, it's mandatory to do an eraseuicr or an eraseall to deactivate the pin reset. That's not done by defaut in the sdk makefiles (sectoreraseonly).
Once explained it seems obvious but when you're debugging firmwares you don't need to add that trouble on top of the pile.
I suggest in the system_nrf52.c to check if the configuration is not correct with something like :
#if !defined (CONFIG_GPIO_AS_PINRESET) if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) == (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) || ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) == (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){ NVIC_SystemReset(); } #endif
Meaning if we didn't enable the pin reset but it is actually enabled on the chip we do a soft reset. That's obvious enough so the user can understand it and erase the uicr manually to solve the situation. We could also directly erase the uicr using the NVMC before rebooting (but perhaps a bit intrusive).
Cheers
Guillaume