The MCLK is the main system clock and the root point of synchronization for all synchronized clocks (MCLK, CPUCLK, ULPCLK, MFCLK, and LFCLK). It is typically the highest speed clock in the system and supports operation up to 80MHz across the full temperature
range of the device. The MCLK tree is the root source for the CPUCLK (in RUN mode), the PD1 high speed peripheral bus clock (in RUN and SLEEP modes), and the ULPCLK low power bus clock (in RUN, SLEEP, STOP, and STANDBY modes). In addition, the 4MHz MFCLK and 32kHz LFCLK outputs are synchronized to MCLK.
The MCLK output to PD1 peripherals is enabled in RUN and SLEEP modes, and disabled in all other power modes. While the MCLK output to PD1 is disabled in STOP and STANDBY modes, the MCLK tree is still running to source ULPCLK and to provide synchronization for MFCLK and LFCLK.
The MCLK source is selected with a glitch free clock mux and can be changed dynamically at runtime by user software. It can also be changed automatically by hardware when
entering STOP and STANDBY modes or during an
asynchronous fast clock request.
The available sources for MCLK include:
- HSCLK (high-speed clock) at up to 80MHz which can be sourced by:
- SYSPLLCLK0 or SYSPLLCLK2X (used to reach the max MCLK speed of 80MHz)
- HFCLK for applications where the main clock needs to be as accurate as possible
- SYSOSC at 4, 16, 24, or 32MHz (the default clock source after reset)
- SYSOSC at 4MHz with MDIV divider (for applications where the peripheral bus and CPU run between 250kHz and 4MHz)
- LFCLK at 32kHz for applications where the entire system, including the CPU, runs at 32kHz with low peak operating current
NOTE: Set SYSPLLCLK0 or SYSPLLCLK2X as the source of HSCLK before setting HSCLK as the clock source of MCLK, otherwise the device can be in an unpredictable state.
Using MCLK in RUN and SLEEP Mode
After boot, MCLK is sourced from SYSOSC by default. The decision of which oscillator to use to source MCLK is important because MCLK sets both the CPUCLK frequency and the bus clock frequency for PD1 peripherals. As a result, the accuracy and the clock speed of the oscillator selected for MCLK must be appropriate not only for the operation of the CPU but also for the
operation of the PD1 peripherals that use the bus clock as their functional clock.
The clock source and frequency selection decisions made for MCLK also affect ULPCLK in RUN and SLEEP modes. See the ULPCLK section for more information on how MCLK and ULPCLK are related in RUN and SLEEP mode.
Using MCLK in STOP and STANDBY Mode
In STOP and STANDBY modes, the MCLK output to PD1 peripherals is disabled, but the
ULPCLK, which is the bus clock for PD0 peripherals, is still active in STOP and optionally active in STANDBY. See the
ULPCLK section for more information on how the
MCLK source and ULPCLK are related in STOP and STANDBY mode.
MCLK Source Selection
Application software can change the MCLK source from SYSOSC to the SYSPLL or to the HFCLK (which is either HFXT or HFCLK_IN) by configuring the MCLKCFG.USEHSCLK and HSCLKCFG.HSCLKSEL
register bits appropriately in SYSCTL. It is also possible to select LFCLK as the MCLK source in all modes by setting MCLKCFG.USELFCLK, giving the low peak current consumption with the CPU and PD1 peripherals operational. The following table gives the proper register bit configurations for selecting different clocks for MCLK in RUN and SLEEP modes.
Table 2-7 MSPM0Gxx MCLK Source Selection in RUN and SLEEP Mode
Desired Source |
MCLKCFG.USEHSCLK |
MCLKCFG.USELFCLK |
HSCLKCFG.HSCLKSEL |
SYSPLLCFG0.MCLK2XVCO |
SYSOSC |
0 |
0 |
Don't care |
Don't care |
SYSPLLCLK0 |
1 |
0 |
0 |
0 |
SYSPLLCLK2X |
1 |
0 |
0 |
1 |
HFCLK |
1 |
0 |
1 |
Don't care |
LFCLK |
0 |
1 |
Don't care |
Don't care |
To switch MCLK from SYSOSC to LFCLK in RUN mode:
- If any high speed oscillators (SYSPLL, HFXT, HFCLK_IN) are enabled, disable them before proceeding
- Verify that MCLK is sourced from SYSOSC (CLKSTATUS.CURMCLKSEL is cleared)
- If SYSOSC is not running at base frequency, and SYSOSC is to be left enabled when switching MCLK to LFCLK, set SYSOSC to base frequency before proceeding
- Set MCLKCFG.USELFCLK to switch MCLK to LFCLK and leave SYSOSC enabled, or set SYSOSCCFG.DISABLE to switch MCLK to LFCLK and disable SYSOSC
To switch MCLK from LFCLK to SYSOSC in RUN mode:
- Verify that MCLK is sourced from LFCLK (CLKSTATUS.CURMCLKSEL is set)
- Clear MCLKCFG.USELFCLK or SYSOSCCFG.DISABLE, whichever was set to switch MCLK to LFCLK
To switch MCLK from SYSOSC to HSCLK:
- Verify that MCLK is sourced from SYSOSC (CLKSTATUS.HSCLKMUX is cleared).
- Enable the desired high speed sources (SYSPLL, HFXT, HFCLK_IN) according to their respective requirements.
- Select the desired HSCLK source through the HSCLKCFG.HSCLKSEL control
- Verify that CLKSTATUS.HSCLKGOOD is set, indicating that the selected HSCLK source is valid.
- Set MCLKCFG.USEHSCLK to switch MCLK to HSCLK.
To switch MCLK from HSCLK to SYSOSC:
- Verify that MCLK is sourced from HSCLK (CLKSTATUS.HSCLKMUX is set).
- Clear MCLKCFG.USEHSCLK to switch MCLK to SYSOSC.
- Wait for CLKSTATUS.HSCLKMUX to clear, indicating that MCLK is now sourced from SYSOSC.
- If desired, disable any high-speed clock sources (SYSPLL or HFXT)
As shown in Table 2-7, the USELFCLK and USEHSCLK bits in MCLKCFG are mutually exclusive and must not be set at the same time. To switch MCLK from LFCLK to HSCLK, or HSCLK to LFCLK, MCLK is first
switched to SYSOSC before switching to the final clock source. The procedures below describe how to switch MCLK from HSCLK to LFCK or from LFCK to HSCLK.
To switch MCLK from HSCLK to LFCLK:
- Verify that MCLK is sourced from HSCLK (CLKSTATUS.HSCLKMUX is set).
- Clear MCLKCFG.USEHSCLK to switch MCLK to SYSOSC
- Wait for CLKSTATUS.HSCLKMUX to clear, indicating that MCLK is now sourced from SYSOSC
- Disable any high speed sources (SYSPLL, HFXT, HFCLK_IN) which were enabled
- Wait for CLKSTATUS.HSCLKSOFF to be asserted, indicating that high-speed clocks are off
- Set MCLKCFG.USELFCLK to switch MCLK to LFCLK while leaving SYSOSC enabled, or set SYSOSCCFG.DISABLE to switch MCLK to LFCLK and disable SYSOSC
To switch MCLK from LFCLK to HSCLK:
- Verify that MCLK is sourced from LFCLK (CLKSTATUS.CURMCLKSEL is set)
- Clear SYSOSCCFG.DISABLE or MCLKCFG.USELFCLK, based on which was set previously
- Wait for CLKSTATUS.CURMCLKSEL to clear, indicating that MCLK is now sourced from SYSOSC
- Enable the desired high speed oscillators (SYSPLL, HFXT, HFCLK_IN) according to their respective requirements
- Select the desired HSCLK source through the HSCLKCFG.HSCLKSEL control
- Verify that CLKSTATUS.HSCLKGOOD is set, indicating that the selected HSCLK source is valid
- Set MCLKCFG.USEHSCLK to switch MCLK to HSCLK
Note: When MCLK is actively sourced by HSCLK (the HSCLKMUX bit in the CLKSTATUS register is set), the HSCLK source selection must not be changed (the HSCLKSEL bit in the HSCLKCFG register and the MCLK2XVCO bit in the SYSPLLCFG0 register must not be changed). To change the HSCLK source, first switch MCLK to SYSOSC using the procedure given above, re-configure the HSCLK source, and then switch MCLK back to
HSCLK.
MCLK Divider (MDIV)
An MCLK source divider (MDIV) is provided to enable MCLK operation in between the lowest SYSOSC frequency (4MHz) and the LFCLK frequency (32kHz). MDIV is for applications with a limited peak current but that still require a higher clock speed than 32kHz. MDIV supports dividing the 4MHz SYSOSC frequency by up to 16, enabling the additional MCLK frequency options given in Table 2-8. For example, a 500kHz MCLK frequency can be obtained by setting SYSOSC to 4MHz and setting MDIV to 7 (divide-by-8).
Table 2-8 shows the MCLK frequency which is realized with /2, /4, /8, and /16 MDIV configurations, but MDIV can be set to any integer divider between /2 and /16 (MDIV register values of 0x1 through 0xF, respectively, with 0x0 disabling the MDIV).
Table 2-8 Typical MCLK Configurations for Operation Between 4MHz and 32kHz
MCLK Source |
MDIV |
MCLK Frequency |
SYSOSC (4MHz) |
0 (Disabled) |
4MHz |
1 (/2) |
2MHz |
3 (/4) |
1MHz |
7 (/8) |
500kHz |
15 (/16) |
250kHz |
To use MDIV to operate MCLK at an intermediate frequency below 4MHz, follow the steps below:
- Disable asynchronous fast clock requests (make sure that the BLOCKASYNCALL bit is set in the in SYSOSCCFG register)
- Make sure that SYSOSC is selected as the MCLK source
- Set the SYSOSC frequency to 4MHz (set the FREQ field in the SYSOSCCFG register to 0x01)
- Delay for 10 MCLK cycles
- Set the desired divider value in the MDIV field in the MCLKCFG register (from 1 to 15, corresponding to /2 to /16, respectively)
Several rules apply when using MDIV to reduce the MCLK frequency:
- MDIV must not be used when high speed oscillators are used to source MCLK (SYSPLL, HFCLK); if SYSPLL or HFCLK are selected to source MCLK, MDIV must be disabled (MCLKCFG.MDIV=0x00)
- The SYSOSC frequency must be kept at 4MHz when MDIV is enabled
- Asynchronous requests to change the SYSOSC frequency must remain blocked
To disable MDIV:
- Disable MDIV (set the MDIV field in the MCLKCFG register to 0x0)
- Wait for 16 MCLK cycles before changing the SYSOSC frequency from 4MHz to another frequency
Note: MDIV does not apply to LFCLK, as MDIV is not in the LFCLK path when LFCLK is selected as the MCLK source. If LFCLK is selected for MCLK, MDIV must be disabled.