How do I turn off the clock for RF? CLOCK_CONTROL_NRF_SUBSYS_HF

Hi,

On nRF52811 I use simple ESB radio for TX.  Before TX I turn Clock for radio on like in the example:

int clocks_start(void)
{
	int err;
	int res;
	struct onoff_manager *clk_mgr;
	struct onoff_client clk_cli;

	clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
	if (!clk_mgr) {
		return -ENXIO;
	}

	sys_notify_init_spinwait(&clk_cli.notify);

	err = onoff_request(clk_mgr, &clk_cli);
	if (err < 0) {
		return err;
	}

	do {
		err = sys_notify_fetch_result(&clk_cli.notify, &res);
		if (!err && res) {

			return res;
		}
	} while (err);

	return 0;
}

After TX is done, I want to turn this clock OFF. I assume at least that I have to do it - because after the TX I want to go to sleep mode with the lowest possible consumption. Now After TX is done, the CPU has nothing to do and the consumption is about 400 uA, when I do not turn the HF clock to ON the power consumption falls down about to 7 uA.

How to turn the clock off? Or something else I need to do?

P.S. Where I can find this kind of information? I am used to work with STM32 - Go to datasheet - find register and coresponding bit, then look in to HAL or LL lib and I am looking for the fuctions which works with this bit it - then I can easily find the function to be called. But in Nordic SDK I am lost.. How do you do that?

Thank you very much

  • Hello,

    Sorry for the delayed response.

    Is there any update at your end?

    What kind of error / issues you got after using that API?

    I started with blinky sample, and then incorporated the header files and then called those functions to enable and disable the HFClock.

    I am repeating in a loop with 10 seconds for each

    In the power profiler, I can see the average current consumption difference

    When the HFClock is ON, average current consumption is ~185uA higher than the case when HFClock is OFF.

    This is how I have defined the sys and dev:

    #define sys CLOCK_CONTROL_NRF_SUBSYS_HF
    static const struct device *const dev = DEVICE_DT_GET_ONE(nordic_nrf_clock);

    /BR, Naeem

  • Thank you very very much, your code saved mea nd it works, I used code bellow, But I would be interested in why the codes below didn't work the same way.

    For Turning Off I used:

    NRF_CLOCK->TASKS_HFCLKSTOP = 1;
    while ((NRF_CLOCK->HFCLKSTAT & (1<<0)));  
    or 
    while(clock_control_off(dev, CLOCK_CONTROL_NRF_SUBSYS_HF) !=0);
    And for On I used:
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    or 
    clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
        if (!clk_mgr) {
            return -ENXIO;
        }

        sys_notify_init_spinwait(&clk_cli.notify);

        err = onoff_request(clk_mgr, &clk_cli);
        if (err < 0) {
            return err;
        }

        do {
            err = sys_notify_fetch_result(&clk_cli.notify, &res);
            if (!err && res) {

                return res;
            }
        } while (err);
  • Did you try and test like the code provided?

Related