mspm0: add HFXT + MCLK source config (G350x)#6222
Open
ozongzi wants to merge 1 commit into
Open
Conversation
Replaces the `// TODO: OSC configuration` placeholder in Config with a `clock` submodule that brings up the external HFXT crystal on PA5/PA6 and optionally switches MCLK over to HSCLK <- HFCLK. Scope: - Gated on the existing `mspm0g350x` family cfg flag. - Bench-validated on MSPM0G3507PM with a 40 MHz crystal driving MCLK. - Same register layout per TI TRM applies to MSPM0G3506; not bench- verified there, so reviewers can widen the gate at their discretion. Out of scope (left for follow-ups): - SYSPLL routing as an HSCLK source. - MDIV and UDIV dividers. - Other families. The `embassy-time` driver runs on LFCLK (32.768 kHz, independent of MCLK), so switching MCLK does not skew Timer durations. A `clock_hfxt` example in `examples/mspm0g3507` demonstrates the new Config fields with a 1 Hz blink. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds MSPM0G350x clock-tree configuration support (HFXT bring-up + optional MCLK switch to HSCLK) and provides an example demonstrating 40 MHz HFXT usage.
Changes:
- Introduces a new
embassy_mspm0::clockmodule (gated tomspm0g350x) with HFXT + MCLK selection configuration. - Extends
embassy_mspm0::Configandinit()to apply clock configuration early during boot. - Adds an MSPM0G3507 example that boots from an external 40 MHz crystal and blinks an LED.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/mspm0g3507/src/bin/clock_hfxt.rs | New example showing how to enable HFXT and switch MCLK to HSCLK. |
| embassy-mspm0/src/lib.rs | Exposes clock module (MSPM0G350x) and wires clock configuration into Config + init(). |
| embassy-mspm0/src/clock.rs | New clock-tree driver implementing HFXT enable and MCLK switch to HSCLK. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| w.set_useexthfclk(false); | ||
| }); | ||
|
|
||
| while !s.clkstatus().read().hfclkgood() {} |
Comment on lines
+154
to
+157
| while !s.clkstatus().read().hsclkgood() {} | ||
|
|
||
| s.mclkcfg().modify(|w| w.set_usehsclk(true)); | ||
| while s.clkstatus().read().hsclkmux() != vals::Hsclkmux::HSCLK {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the
// TODO: OSC configurationplaceholder in Config with aclocksubmodule that brings up the external HFXT crystal on PA5/PA6 and optionally switches MCLK over to HSCLK <- HFCLK.Scope:
mspm0g350xfamily cfg flag.Out of scope (left for follow-ups):
The
embassy-timedriver runs on LFCLK (32.768 kHz, independent of MCLK), so switching MCLK does not skew Timer durations.A
clock_hfxtexample inexamples/mspm0g3507demonstrates the new Config fields with a 1 Hz blink.