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

Related