How to completely turn off the radio (power consumption test)

SDK: nRF Connect SDK v2.9.0

Chipset: nRF52840

I'm using ncsv2.9.0nrfsamplesperipheralradio_test to test the RF.

The initialization code is as follows:

            struct radio_test_config test_config;
            memset(&test_config, 0, sizeof(test_config));
            test_config.type = UNMODULATED_TX;
            test_config.mode = NRF_RADIO_MODE_BLE_1MBIT;
            test_config.params.unmodulated_tx.txpower = RADIO_TXPOWER_TXPOWER_Pos8dBm;
            test_config.params.unmodulated_tx.channel = 2;
            radio_test_init(&test_config);
            radio_test_start(&test_config);

At this time, the measured current is approximately 15.35mA.

Cancel code:

radio_test_cancel();

After canceling the RF output, the measured current is about 15.3mA, which indicates that the radio does not seem to be turned off.

How can I completely turn off the radio?

Parents
  • Hi Leo

    I will look into your case. Just from the looks of it, it seems like you have modified the sample. Is this correct? Normally you would configure the application over CLI, are you doing it?
    Regards

    Runar

  •   

    Hi runsiv 

    I have fully ported the radio_test code now, but even after turning off the radio, there is still a current of 480+uA.

  • Hi,

    The current consumption is pretty inline with hfclk is running, can you look at trying to stop the hfclk if you haven't already?

    Kenneth

  • Hi Kenneth,

    Thank you very much! I fixed it.

    Code:

    static struct onoff_manager *get_mgr(void)
    {
    	return z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
    }
    
    static bool clock_is_off(void)
    {
    	const struct device *const clk = DEVICE_DT_GET_ONE(nordic_nrf_clock);
    
    	if (!device_is_ready(clk)) {
    		
    		LOG_ERR("Device is not ready");	
    	}
    
    	return clock_control_get_status(clk, CLOCK_CONTROL_NRF_SUBSYS_HF) ==
    			CLOCK_CONTROL_STATUS_OFF;
    }
    
    static void clock_off(void)
    {
    	struct onoff_manager *mgr = get_mgr();
    
    	do {
    		(void)onoff_release(mgr);
    
    	} while (!clock_is_off());
    }
    
    static void clock_set(bool on_off)
    {
    	struct onoff_client cli;
    	struct onoff_manager *mgr = get_mgr();
    	int err = 0;
    
    	if (on_off) {
    
    		sys_notify_init_spinwait(&cli.notify);
    		err = onoff_request(mgr, &cli);
    		
    		if (err >= 0) {
    
    			while (sys_notify_fetch_result(&cli.notify, &err) < 0) {
    				/* empty */
    			}
    		} 
    	} else {
    
    		clock_off();
    	}
    	
    	LOG_INF("Clock set %s, err %d", on_off?"on":"off", err);
    }

Reply
  • Hi Kenneth,

    Thank you very much! I fixed it.

    Code:

    static struct onoff_manager *get_mgr(void)
    {
    	return z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
    }
    
    static bool clock_is_off(void)
    {
    	const struct device *const clk = DEVICE_DT_GET_ONE(nordic_nrf_clock);
    
    	if (!device_is_ready(clk)) {
    		
    		LOG_ERR("Device is not ready");	
    	}
    
    	return clock_control_get_status(clk, CLOCK_CONTROL_NRF_SUBSYS_HF) ==
    			CLOCK_CONTROL_STATUS_OFF;
    }
    
    static void clock_off(void)
    {
    	struct onoff_manager *mgr = get_mgr();
    
    	do {
    		(void)onoff_release(mgr);
    
    	} while (!clock_is_off());
    }
    
    static void clock_set(bool on_off)
    {
    	struct onoff_client cli;
    	struct onoff_manager *mgr = get_mgr();
    	int err = 0;
    
    	if (on_off) {
    
    		sys_notify_init_spinwait(&cli.notify);
    		err = onoff_request(mgr, &cli);
    		
    		if (err >= 0) {
    
    			while (sys_notify_fetch_result(&cli.notify, &err) < 0) {
    				/* empty */
    			}
    		} 
    	} else {
    
    		clock_off();
    	}
    	
    	LOG_INF("Clock set %s, err %d", on_off?"on":"off", err);
    }

Children
No Data
Related