questions about Zephyr clock control

Hello DevZone,

I have learned that some knowledge about CLOCK. But they are a little bit confusing. I just want to get confirmed by any expert.

1. Some peripherals (like TIMER, PDM) may need HFXO to get better accuracy. So, we should use `onoff_manager` to start the HFXO. Is that correct?

for 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) {
		LOG_ERR("Unable to get the Clock manager\n");
		return -ENXIO;
	}

	sys_notify_init_spinwait(&clk_cli.notify);

	err = onoff_request(clk_mgr, &clk_cli);
	if (err < 0) {
		LOG_ERR("Clock request failed: %d\n", err);
		return err;
	}

	do {
		err = sys_notify_fetch_result(&clk_cli.notify, &res);
		if (!err && res) {
			LOG_ERR("Clock could not be started: %d\n", res);
			return res;
		}
	} while (err);

#if defined(NRF54L15_XXAA)
	/* MLTPAN-20 */
	nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
#endif /* defined(NRF54L15_XXAA) */

	LOG_INF("HF clock started\n");
	return 0;
}

In this context, the `CLOCK_CONTROL_NRF_SUBSYS_HF` means HFXO, not the HFINT. Is that correct? (While in the datasheet, HFCLK can be one of HFXO or HFINT) 

And when the `CLOCK_CONTROL_NRF_SUBSYS_HF` is enabled, the peripherals (like TIMER, PDM) will automatically change the clock source to HFXO. Is that correct?

2. We know that the wireless protocols (BLE, Thread...) are based on MPSL, because they need HFXO. And the MPSL will automatically enable and disable the HFCLK during the timeslot.

In this situation, can I still use OnOff Manager to control the HFXO for the peripherals (like TIMER, PDM)? I'm afraid not. But I'm not sure.

3. If I want to use BLE and PDM at the same time. Do I need to use MPSL and sample the audio data during the MPSL slot?

Best regards,

Jayant

Parents
  • Hi Jayant,

    1. Some peripherals (like TIMER, PDM) may need HFXO to get better accuracy. So, we should use `onoff_manager` to start the HFXO. Is that correct?

    Yes, that is correct. Peripherals tha tneed the HFCLK will request it in hardware, but by default that will just start the HFINT. To use the HFXO, that must be started explicitly (the user do not need to think about his when using Bluetooth or other radio protocols, as the stack implementation starts the HFXO).

    2. We know that the wireless protocols (BLE, Thread...) are based on MPSL, because they need HFXO. And the MPSL will automatically enable and disable the HFCLK during the timeslot.

    In this situation, can I still use OnOff Manager to control the HFXO for the peripherals (like TIMER, PDM)? I'm afraid not. But I'm not sure.

    Yes, you can use the on/off manager also when MPSL is used. As long as the application enabled the HFXO, it will be kept on even when the stack no longer needs it (and vise versa), and disabled when there are no "users" needing the HFXO.

    3. If I want to use BLE and PDM at the same time. Do I need to use MPSL and sample the audio data during the MPSL slot?

    AS long as you use BLE and the SoftDevic econtroller, you will also use MPSL. But that does not play a part in PDM. YOu can use PDM as in any other case (though there will be times where there are interrupts that block PDM opertaion), so it makes sense to use long DMA transactions so that delays in CPU processing due to interrupts does not cause problems for PDM. This is also a generic problem that needs to be handled in other caes where you have several real time operations concurrently on the same CPU.

    Br,

    Einar

Reply
  • Hi Jayant,

    1. Some peripherals (like TIMER, PDM) may need HFXO to get better accuracy. So, we should use `onoff_manager` to start the HFXO. Is that correct?

    Yes, that is correct. Peripherals tha tneed the HFCLK will request it in hardware, but by default that will just start the HFINT. To use the HFXO, that must be started explicitly (the user do not need to think about his when using Bluetooth or other radio protocols, as the stack implementation starts the HFXO).

    2. We know that the wireless protocols (BLE, Thread...) are based on MPSL, because they need HFXO. And the MPSL will automatically enable and disable the HFCLK during the timeslot.

    In this situation, can I still use OnOff Manager to control the HFXO for the peripherals (like TIMER, PDM)? I'm afraid not. But I'm not sure.

    Yes, you can use the on/off manager also when MPSL is used. As long as the application enabled the HFXO, it will be kept on even when the stack no longer needs it (and vise versa), and disabled when there are no "users" needing the HFXO.

    3. If I want to use BLE and PDM at the same time. Do I need to use MPSL and sample the audio data during the MPSL slot?

    AS long as you use BLE and the SoftDevic econtroller, you will also use MPSL. But that does not play a part in PDM. YOu can use PDM as in any other case (though there will be times where there are interrupts that block PDM opertaion), so it makes sense to use long DMA transactions so that delays in CPU processing due to interrupts does not cause problems for PDM. This is also a generic problem that needs to be handled in other caes where you have several real time operations concurrently on the same CPU.

    Br,

    Einar

Children
No Data
Related