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

nrf52832 debug mode

Hi, I am using nrf52832_xxaa with SDK v11.0.I have the requirement to disable the debug at the start of the program.(Also to enable it if required in the future).

I use the following code at the start of the main function to write into the APPROTECT register to disable the debug mode.The softdevice is disabled.

        uint8_t retry = 10;          /// retry count
        if( ( NRF_UICR->APPROTECT & 0xFF ) == 0xFF )
        {
    
            NRF_NVMC->CONFIG = ( NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos );
            do
            {
                if( ( --retry ) == 0 )
                {
                    NVIC_SystemReset();
                }
            }
            while( NRF_NVMC->READY == NVMC_READY_READY_Busy );
    
            NRF_UICR->APPROTECT = 0;
    
            retry = 10;
            NRF_NVMC->CONFIG = ( NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos );
            do
            {
                if( ( --retry ) == 0 )
                {
                    break;
                }
            }
            while( NRF_NVMC->READY == NVMC_READY_READY_Busy );
            NVIC_SystemReset();
        }

Is it the proper way to disable the debug mode? Or is there any other method?

Do we need need to configure clock or need to enable softdevice before applying changes?

What are the other parameters to be considered when disabling debug mode?

Related