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

Butttonless DFU issue with CONFIG_NFCT_PINS_AS_GPIOS

I am using nrf52832 for button less DFU. DFU is working fine when  CONFIG_NFCT_PINS_AS_GPIOS is not added in applicaton. When added seems like code is getting reset at bootloader level. Is any connection with CONFIG_NFCT_PINS_AS_GPIOS ? Please suggest.

Thanks

  • If you do not want to use pin 21 as the reset pin then you should remove the CONFIG_GPIO_AS_PINRESET definition from the preprocessor definitions, not comment out the code.

    Where you running the code above, i.e.

    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){};
    NRF_NVMC->ERASEUICR = NVMC_ERASEUICR_ERASEUICR_Erase;
    NRF_UICR->PSELRESET[0] = 0xFFFFFFFF ;
    NRF_UICR->PSELRESET[1] = 0xFFFFFFFF ;
    NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
    while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}

    in the bootloader? If so it is no wonder the chip kept resetting as the following code will be executed in the application by SystemInit() in system_nRF52.c if CONFIG_GPIO_AS_PINRESET is defined 

        #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))){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[0] = 21;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[1] = 21;
                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){}
                NVIC_SystemReset();
            }
        #endif

    As you can see it will write pin 21 to the PSELRESET registers and then perform a System Reset for the change to take effect. So you when you set the PSELRESET to 0xFFFFFFF in the bootloader, then the application would write them back to pin 21 and then reset. This would be repeated for infinity. 

    So just remove CONFIG_GPIO_AS_PINRESET in both the application and the bootloader project and you should see things behave as normal. 

    Best regards

    Bjørn

  • Yes actually i already removed it my code. For safe side I added to reconfig PSELRESET. I removed everything, now its working fine.

    Thanks

Related