Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf53: Add APIs to change Low Frequency Clock source in the runtime #2993

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

m-gorecki
Copy link
Contributor

This adds the same API for appcore and netcore.

NRF_CLOCK_NS->TASKS_LFCLKSTOP = 1;
NRF_CLOCK_NS->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK_NS->LFCLKSRC = clksrc;
NRF_CLOCK_NS->TASKS_LFCLKSTART = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lfclk source can be changes without restarting lfclk:
The LFCLK source can be configured at any time (for instance, when the LFCLK has already been started). The content of the LFCLKSRC register only takes effect when the LFCLKSTART task is triggered.

so we can only start lfclk once on system startup, then this API can change source at any time only taking care of hfxo when switching to/from lfsynth

} else {
nrf5340_net_clock_hfxo_request();
}
} else if ((NRF_CLOCK_NS->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk) ==
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFCLKSRC can be used instead of masking

(CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos)) {
NRF_CLOCK_NS->EVENTS_HFCLKSTARTED = 0;
nrf5340_net_clock_hfxo_request();
while (1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while (!NRF_CLOCK_NS->EVENTS_HFCLKSTARTED) {
}

Code from function hal_system_clock_start was moved into new API,
so now we can call that API with proper argument to avoid code
repetition.
Code from function hal_system_clock_start was moved into new API,
so now we can call that API with proper argument to avoid code
repetition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants