Macros | Functions
CS

Clock System module responsible for setting up and manipulating MSP432's various clocking systems. More...

Macros

#define CS_CLOCK_DIVIDER_1   CS_CTL1_DIVS_0
 
#define CS_CLOCK_DIVIDER_2   CS_CTL1_DIVS_1
 
#define CS_CLOCK_DIVIDER_4   CS_CTL1_DIVS_2
 
#define CS_CLOCK_DIVIDER_8   CS_CTL1_DIVS_3
 
#define CS_CLOCK_DIVIDER_16   CS_CTL1_DIVS_4
 
#define CS_CLOCK_DIVIDER_32   CS_CTL1_DIVS_5
 
#define CS_CLOCK_DIVIDER_64   CS_CTL1_DIVS_6
 
#define CS_CLOCK_DIVIDER_128   CS_CTL1_DIVS_7
 
#define CS_LFXTCLK_SELECT   CS_CTL1_SELM_0
 
#define CS_HFXTCLK_SELECT   CS_CTL1_SELM_5
 
#define CS_VLOCLK_SELECT   CS_CTL1_SELM_1
 
#define CS_REFOCLK_SELECT   CS_CTL1_SELM_2
 
#define CS_DCOCLK_SELECT   CS_CTL1_SELM_3
 
#define CS_MODOSC_SELECT   CS_CTL1_SELM_4
 
#define CS_KEY   0x695A
 
#define CS_ACLK_DIV_BITPOS   0x04
 
#define CS_MCLK_DIV_BITPOS   0x0C
 
#define CS_SMCLK_DIV_BITPOS   0x00
 
#define CS_HSMCLK_DIV_BITPOS   0x08
 
#define CS_ACLK_SRC_BITPOS   0x08
 
#define CS_MCLK_SRC_BITPOS   0x00
 
#define CS_SMCLK_SRC_BITPOS   0x04
 
#define CS_HSMCLK_SRC_BITPOS   0x04
 
#define CS_REFO_32KHZ   0x00
 
#define CS_REFO_128KHZ   0x01
 
#define CS_VLOCLK_FREQUENCY   10000
 
#define CS_MODCLK_FREQUENCY   24000000
 
#define CS_LFXT_FAULT   CS_IE_LFXTIE
 
#define CS_HFXT_FAULT   CS_IE_HFXTIE
 
#define CS_DCO_OPEN_FAULT   CS_IE_DCOR_OPNIE
 
#define CS_STARTCOUNT_LFXT_FAULT   CS_IE_FCNTLFIE
 
#define CS_STARTCOUNT_HFXT_FAULT   CS_IE_FCNTHFIE
 
#define CS_DCO_SHORT_FAULT   CS_IFG_DCOR_SHTIFG
 
#define CS_HFXT_DRIVE   CS_CTL2_HFXTDRIVE
 
#define CS_HFXT_BYPASS   CS_CTL2_HFXTBYPASS
 
#define CS_LFXT_DRIVE0   CS_CTL2_LFXTDRIVE_0
 
#define CS_LFXT_DRIVE1   CS_CTL2_LFXTDRIVE_1
 
#define CS_LFXT_DRIVE2   CS_CTL2_LFXTDRIVE_2
 
#define CS_LFXT_DRIVE3   CS_CTL2_LFXTDRIVE_3
 
#define CS_LFXT_BYPASS   CS_CTL2_LFXTBYPASS
 
#define CS_ACLK   CS_CLKEN_ACLK_EN
 
#define CS_MCLK   CS_CLKEN_MCLK_EN
 
#define CS_SMCLK   CS_CLKEN_SMCLK_EN
 
#define CS_HSMCLK   CS_CLKEN_HSMCLK_EN
 
#define CS_BCLK   CS_STAT_BCLK_READY
 
#define CS_LFXTCLK   0x01
 
#define CS_1MHZ   1000000
 
#define CS_15MHZ   1500000
 
#define CS_3MHZ   3000000
 
#define CS_4MHZ   4000000
 
#define CS_6MHZ   6000000
 
#define CS_8MHZ   8000000
 
#define CS_12MHZ   12000000
 
#define CS_16MHZ   16000000
 
#define CS_24MHZ   24000000
 
#define CS_32MHZ   32000000
 
#define CS_40MHZ   40000000
 
#define CS_48MHZ   48000000
 
#define CS_DCO_FREQUENCY_1_5   CS_CTL0_DCORSEL_0
 
#define CS_DCO_FREQUENCY_3   CS_CTL0_DCORSEL_1
 
#define CS_DCO_FREQUENCY_6   CS_CTL0_DCORSEL_2
 
#define CS_DCO_FREQUENCY_12   CS_CTL0_DCORSEL_3
 
#define CS_DCO_FREQUENCY_24   CS_CTL0_DCORSEL_4
 
#define CS_DCO_FREQUENCY_48   CS_CTL0_DCORSEL_5
 
#define CS_HFXT_FAULT_COUNTER   0x01
 
#define CS_LFXT_FAULT_COUNTER   0x02
 
#define CS_FAULT_COUNTER_4096_CYCLES   CS_CTL3_FCNTLF_0
 
#define CS_FAULT_COUNTER_8192_CYCLES   CS_CTL3_FCNTLF_1
 
#define CS_FAULT_COUNTER_16384_CYCLES   CS_CTL3_FCNTLF_2
 
#define CS_FAULT_COUNTER_32768_CYCLES   CS_CTL3_FCNTLF_3
 
#define CS_OVER32MHZ   0x01
 
#define CS_UNDER32MHZ   0x02
 
#define DEVICE_PG1_1   0x42
 

Functions

void CS_setExternalClockSourceFrequency (uint32_t lfxt_XT_CLK_frequency, uint32_t hfxt_XT_CLK_frequency)
 
void CS_initClockSignal (uint32_t selectedClockSignal, uint32_t clockSource, uint32_t clockSourceDivider)
 
bool CS_startHFXT (bool bypassMode)
 
bool CS_startHFXTWithTimeout (bool bypassMode, uint32_t timeout)
 
bool CS_startLFXT (uint32_t xtDrive)
 
bool CS_startLFXTWithTimeout (uint32_t xtDrive, uint32_t timeout)
 
void CS_setReferenceOscillatorFrequency (uint8_t referenceFrequency)
 
void CS_enableClockRequest (uint32_t selectClock)
 
void CS_disableClockRequest (uint32_t selectClock)
 
uint32_t CS_getACLK (void)
 
uint32_t CS_getSMCLK (void)
 
uint32_t CS_getMCLK (void)
 
uint32_t CS_getBCLK (void)
 
uint32_t CS_getHSMCLK (void)
 
void CS_setDCOCenteredFrequency (uint32_t dcoFreq)
 
void CS_setDCOFrequency (uint32_t dcoFrequency)
 
void CS_tuneDCOFrequency (int16_t tuneParameter)
 
void CS_enableDCOExternalResistor (void)
 
void CS_disableDCOExternalResistor (void)
 
void CS_setDCOExternalResistorCalibration (uint_fast8_t uiCalData, uint_fast8_t freqRange)
 
uint32_t CS_getDCOFrequency (void)
 
void CS_enableFaultCounter (uint_fast8_t counterSelect)
 
void CS_disableFaultCounter (uint_fast8_t counterSelect)
 
void CS_resetFaultCounter (uint_fast8_t counterSelect)
 
void CS_startFaultCounter (uint_fast8_t counterSelect, uint_fast8_t countValue)
 
void CS_enableInterrupt (uint32_t flags)
 
void CS_disableInterrupt (uint32_t flags)
 
uint32_t CS_getEnabledInterruptStatus (void)
 
uint32_t CS_getInterruptStatus (void)
 
void CS_clearInterruptFlag (uint32_t flags)
 
void CS_registerInterrupt (void(*intHandler)(void))
 
void CS_unregisterInterrupt (void)
 

Detailed Description

Clock System module responsible for setting up and manipulating MSP432's various clocking systems.


Clock System (CS) Module Operation


The clock system module for DriverLib gives users the ability to fully configure and control all aspects of the MSP432 clock system. This includes initializing and maintaining the MCLK, ACLK, HSMCLK, SMCLK, and BCLK clock systems. Additionally, APIs exist for configuring connected crystal oscillators as well as configuring/manipulating the DCO and reference oscillator.


Timeout Parameters


For crystal configuration APIs (starting the LFXT and HFXT), a "timeout" API exists that will return control of execution back to the user application if a specified duration passes. The variable that is passed into these functions is a unit of time specified by how many "loop iterations" elapse before unsuccessful stabilization of the respected crystal. The API will attempt to check to see if there was a crystal fault, clear the crystal fault flag, and repeat the check until no fault exists. If the user calls the API with a specified timeout, the loop will only check the given number of loop iterations for a successfully stabilized crystal.


Custom DCO Frequency


For tuning the DCO frequency to a specific frequency, a convenient CS_setDCOFrequency function is provided to users. This function accepts any uint32_t frequency and automatically calculates the appropriate tuning parameters to get the DCO frequency as close as possible to the provided frequency. Note that with this function, floating point math is involved so if efficiency is a concern the user should enable the FPU using the FPU_enableModule function.


Specifying External Crystal Frequencies


MSP432 DriverLib has a variety of convenience functions for obtaining the specific frequency of a clock source ( such as CS_getMCLK ). If a clock source is sourced from an external crystal, the crystal frequency must be specified explicitly using the CS_setExternalClockSourceFrequency function. This function must be used prior to the getters for the clock source if an external crystal is used.


Programming Example


The DriverLib package contains a variety of different code examples that demonstrate the usage of the CS module. These code examples are accessible under the examples/ folder of the MSPWare release as well as through TI Resource Explorer if using Code Composer Studio. These code examples provide a comprehensive list of use cases as well as practical applications involving each module.

Below is a very brief code example showing how to start the external high frequency crystal and source MCLK from this crystal. An LED is configured as an output in this example as well. For a set of more detailed code examples, please refer to the code examples in the examples/ directory of the MSPWare release:

/* Configuring pins for peripheral/crystal usage and LED for output */
/* Just in case the user wants to use the getACLK, getMCLK, etc. functions,
* let's set the clock frequency in the code.
*/
/* Starting HFXT in non-bypass mode without a timeout. Before we start
* we have to change VCORE to 1 to support the 48MHz frequency */
CS_startHFXT(false);
/* Initializing MCLK to HFXT (effectively 48MHz) */

Macro Definition Documentation

#define CS_CLOCK_DIVIDER_1   CS_CTL1_DIVS_0

Referenced by CS_getBCLK().

#define CS_CLOCK_DIVIDER_2   CS_CTL1_DIVS_1
#define CS_CLOCK_DIVIDER_4   CS_CTL1_DIVS_2
#define CS_CLOCK_DIVIDER_8   CS_CTL1_DIVS_3
#define CS_CLOCK_DIVIDER_16   CS_CTL1_DIVS_4
#define CS_CLOCK_DIVIDER_32   CS_CTL1_DIVS_5
#define CS_CLOCK_DIVIDER_64   CS_CTL1_DIVS_6
#define CS_CLOCK_DIVIDER_128   CS_CTL1_DIVS_7
#define CS_LFXTCLK_SELECT   CS_CTL1_SELM_0

Referenced by CS_getBCLK(), and CS_initClockSignal().

#define CS_HFXTCLK_SELECT   CS_CTL1_SELM_5

Referenced by CS_initClockSignal().

#define CS_VLOCLK_SELECT   CS_CTL1_SELM_1
#define CS_REFOCLK_SELECT   CS_CTL1_SELM_2

Referenced by CS_getBCLK(), and CS_initClockSignal().

#define CS_DCOCLK_SELECT   CS_CTL1_SELM_3

Referenced by CS_initClockSignal().

#define CS_MODOSC_SELECT   CS_CTL1_SELM_4

Referenced by CS_initClockSignal().

#define CS_KEY   0x695A
#define CS_ACLK_DIV_BITPOS   0x04

Referenced by CS_getACLK(), and CS_initClockSignal().

#define CS_MCLK_DIV_BITPOS   0x0C

Referenced by CS_getMCLK(), and CS_initClockSignal().

#define CS_SMCLK_DIV_BITPOS   0x00

Referenced by CS_initClockSignal().

#define CS_HSMCLK_DIV_BITPOS   0x08

Referenced by CS_getHSMCLK(), and CS_initClockSignal().

#define CS_ACLK_SRC_BITPOS   0x08

Referenced by CS_getACLK(), and CS_initClockSignal().

#define CS_MCLK_SRC_BITPOS   0x00

Referenced by CS_getMCLK(), and CS_initClockSignal().

#define CS_SMCLK_SRC_BITPOS   0x04
#define CS_HSMCLK_SRC_BITPOS   0x04
#define CS_REFO_32KHZ   0x00
#define CS_REFO_128KHZ   0x01
#define CS_VLOCLK_FREQUENCY   10000
#define CS_MODCLK_FREQUENCY   24000000
#define CS_LFXT_FAULT   CS_IE_LFXTIE
#define CS_HFXT_FAULT   CS_IE_HFXTIE
#define CS_DCO_OPEN_FAULT   CS_IE_DCOR_OPNIE
#define CS_STARTCOUNT_LFXT_FAULT   CS_IE_FCNTLFIE
#define CS_STARTCOUNT_HFXT_FAULT   CS_IE_FCNTHFIE
#define CS_DCO_SHORT_FAULT   CS_IFG_DCOR_SHTIFG
#define CS_HFXT_DRIVE   CS_CTL2_HFXTDRIVE
#define CS_HFXT_BYPASS   CS_CTL2_HFXTBYPASS
#define CS_LFXT_DRIVE0   CS_CTL2_LFXTDRIVE_0

Referenced by CS_startLFXTWithTimeout().

#define CS_LFXT_DRIVE1   CS_CTL2_LFXTDRIVE_1

Referenced by CS_startLFXTWithTimeout().

#define CS_LFXT_DRIVE2   CS_CTL2_LFXTDRIVE_2

Referenced by CS_startLFXTWithTimeout().

#define CS_LFXT_DRIVE3   CS_CTL2_LFXTDRIVE_3

Referenced by CS_startLFXTWithTimeout().

#define CS_LFXT_BYPASS   CS_CTL2_LFXTBYPASS

Referenced by CS_startLFXTWithTimeout().

#define CS_ACLK   CS_CLKEN_ACLK_EN
#define CS_MCLK   CS_CLKEN_MCLK_EN
#define CS_SMCLK   CS_CLKEN_SMCLK_EN
#define CS_HSMCLK   CS_CLKEN_HSMCLK_EN
#define CS_BCLK   CS_STAT_BCLK_READY

Referenced by CS_initClockSignal().

#define CS_LFXTCLK   0x01
#define CS_1MHZ   1000000
#define CS_15MHZ   1500000

Referenced by CS_setDCOFrequency().

#define CS_3MHZ   3000000

Referenced by CS_setDCOFrequency().

#define CS_4MHZ   4000000
#define CS_6MHZ   6000000

Referenced by CS_setDCOFrequency().

#define CS_8MHZ   8000000
#define CS_12MHZ   12000000

Referenced by CS_setDCOFrequency().

#define CS_16MHZ   16000000
#define CS_24MHZ   24000000

Referenced by CS_setDCOFrequency().

#define CS_32MHZ   32000000
#define CS_40MHZ   40000000
#define CS_48MHZ   48000000

Referenced by CS_setDCOFrequency().

#define CS_DCO_FREQUENCY_1_5   CS_CTL0_DCORSEL_0
#define CS_DCO_FREQUENCY_3   CS_CTL0_DCORSEL_1
#define CS_DCO_FREQUENCY_6   CS_CTL0_DCORSEL_2
#define CS_DCO_FREQUENCY_12   CS_CTL0_DCORSEL_3
#define CS_DCO_FREQUENCY_24   CS_CTL0_DCORSEL_4
#define CS_DCO_FREQUENCY_48   CS_CTL0_DCORSEL_5
#define CS_HFXT_FAULT_COUNTER   0x01
#define CS_LFXT_FAULT_COUNTER   0x02
#define CS_FAULT_COUNTER_4096_CYCLES   CS_CTL3_FCNTLF_0

Referenced by CS_startFaultCounter().

#define CS_FAULT_COUNTER_8192_CYCLES   CS_CTL3_FCNTLF_1

Referenced by CS_startFaultCounter().

#define CS_FAULT_COUNTER_16384_CYCLES   CS_CTL3_FCNTLF_2

Referenced by CS_startFaultCounter().

#define CS_FAULT_COUNTER_32768_CYCLES   CS_CTL3_FCNTLF_3

Referenced by CS_startFaultCounter().

#define CS_OVER32MHZ   0x01
#define CS_UNDER32MHZ   0x02
#define DEVICE_PG1_1   0x42

Function Documentation

void CS_setExternalClockSourceFrequency ( uint32_t  lfxt_XT_CLK_frequency,
uint32_t  hfxt_XT_CLK_frequency 
)

This function sets the external clock sources LFXT and HFXT crystal oscillator frequency values. This function must be called if an external crystal LFXT or HFXT is used and the user intends to call CS_getSMCLK, CS_getMCLK, CS_getBCLK, CS_getHSMCLK, CS_getACLK and any of the HFXT oscillator control functions

Parameters
lfxt_XT_CLK_frequencyis the LFXT crystal frequencies in Hz
hfxt_XT_CLK_frequencyis the HFXT crystal frequencies in Hz
Returns
None
void CS_initClockSignal ( uint32_t  selectedClockSignal,
uint32_t  clockSource,
uint32_t  clockSourceDivider 
)

This function initializes each of the clock signals. The user must ensure that this function is called for each clock signal. If not, the default state is assumed for the particular clock signal. Refer to DriverLib documentation for CS module or Device Family User's Guide for details of default clock signal states.

Note that this function is blocking and will wait on the appropriate bit to be set in the CSSTAT READY register to be set before setting the clock source.

Also note that when HSMCLK and SMCLK share the same clock signal. If you change the clock signal for HSMCLK, the clock signal for SMCLK will change also (and vice-versa).

HFXTCLK is not available for BCLK or ACLK.

Parameters
selectedClockSignalClock signal to initialize.
  • CS_ACLK,
  • CS_MCLK,
  • CS_HSMCLK
  • CS_SMCLK
  • CS_BCLK [clockSourceDivider is ignored for this parameter]
clockSourceClock source for the selectedClockSignal signal.
  • CS_LFXTCLK_SELECT,
  • CS_HFXTCLK_SELECT,
  • CS_VLOCLK_SELECT, [Not available for BCLK]
  • CS_DCOCLK_SELECT, [Not available for ACLK, BCLK]
  • CS_REFOCLK_SELECT,
  • CS_MODOSC_SELECT [Not available for ACLK, BCLK]
clockSourceDivider- selected the clock divider to calculate clock signal from clock source. This parameter is ignored when setting BLCK. Valid values are:
  • CS_CLOCK_DIVIDER_1,
  • CS_CLOCK_DIVIDER_2,
  • CS_CLOCK_DIVIDER_4,
  • CS_CLOCK_DIVIDER_8,
  • CS_CLOCK_DIVIDER_16,
  • CS_CLOCK_DIVIDER_32,
  • CS_CLOCK_DIVIDER_64,
  • CS_CLOCK_DIVIDER_128
Returns
NONE

References ASSERT, CS_ACLK, CS_ACLK_DIV_BITPOS, CS_ACLK_SRC_BITPOS, CS_BCLK, CS_DCOCLK_SELECT, CS_HFXTCLK_SELECT, CS_HSMCLK, CS_HSMCLK_DIV_BITPOS, CS_HSMCLK_SRC_BITPOS, CS_KEY, CS_LFXTCLK_SELECT, CS_MCLK, CS_MCLK_DIV_BITPOS, CS_MCLK_SRC_BITPOS, CS_MODOSC_SELECT, CS_REFOCLK_SELECT, CS_SMCLK, and CS_SMCLK_DIV_BITPOS.

bool CS_startHFXT ( bool  bypassMode)

Initializes the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 48 MHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared, with no timeout. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CS_setExternalClockSourceFrequency to set frequency of external clocks before calling this function.

Parameters
bypassModeWhen this variable is set, the oscillator will start in bypass mode and the signal can be generated by a digital square wave.
Returns
true if started correctly, false otherwise

References CS_startHFXTWithTimeout().

bool CS_startHFXTWithTimeout ( bool  bypassMode,
uint32_t  timeout 
)

Initializes the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 48 MHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared, with no timeout. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CS_setExternalClockSourceFrequency to set frequency of external clocks before calling this function. This function has a timeout associated with stabilizing the oscillator.

Parameters
bypassModeWhen this variable is set, the oscillator will start in bypass mode and the signal can be generated by a digital square wave.
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.
Returns
true if started correctly, false otherwise

References CS_KEY, SYSCTL_CS_SRC, SysCtl_disableNMISource(), SysCtl_enableNMISource(), and SysCtl_getNMISourceStatus().

Referenced by CS_startHFXT().

bool CS_startLFXT ( uint32_t  xtDrive)

Initializes the LFXT crystal oscillator, which supports crystal frequencies up to 50kHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared, with no timeout. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CS_setExternalClockSourceFrequency to set frequency of external clocks before calling this function.

Parameters
xtDriveis the target drive strength for the LFXT crystal oscillator. Valid values are:
  • CS_LFXT_DRIVE0,
  • CS_LFXT_DRIVE1,
  • CS_LFXT_DRIVE2,
  • CS_LFXT_DRIVE3, [Default Value]
  • CS_LFXT_BYPASS
Note
When CS_LFXT_BYPASS is passed as a parameter the oscillator will start in bypass mode and the signal can be generated by a digital square wave.
Returns
true if started correctly, false otherwise

References CS_startLFXTWithTimeout().

bool CS_startLFXTWithTimeout ( uint32_t  xtDrive,
uint32_t  timeout 
)

Initializes the LFXT crystal oscillator, which supports crystal frequencies up to 50kHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CS_setExternalClockSourceFrequency to set frequency of external clocks before calling this function. This function has a timeout associated with stabilizing the oscillator.

Parameters
xtDriveis the target drive strength for the LFXT crystal oscillator. Valid values are:
  • CS_LFXT_DRIVE0,
  • CS_LFXT_DRIVE1,
  • CS_LFXT_DRIVE2,
  • CS_LFXT_DRIVE3, [Default Value]
  • CS_LFXT_BYPASS
Note
When CS_LFXT_BYPASS is passed as a parameter the oscillator will start in bypass mode and the signal can be generated by a digital square wave.
Parameters
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.
Returns
true if started correctly, false otherwise

References ASSERT, CS_KEY, CS_LFXT_BYPASS, CS_LFXT_DRIVE0, CS_LFXT_DRIVE1, CS_LFXT_DRIVE2, CS_LFXT_DRIVE3, SYSCTL_CS_SRC, SysCtl_disableNMISource(), SysCtl_enableNMISource(), and SysCtl_getNMISourceStatus().

Referenced by CS_startLFXT().

void CS_setReferenceOscillatorFrequency ( uint8_t  referenceFrequency)

Selects between the frequency of the internal REFO clock source

Parameters
referenceFrequencyselects between the valid frequencies:
  • CS_REFO_32KHZ,
  • CS_REFO_128KHZ,
Returns
NONE

References ASSERT, CS_KEY, CS_REFO_128KHZ, and CS_REFO_32KHZ.

void CS_enableClockRequest ( uint32_t  selectClock)

Enables conditional module requests

Parameters
selectClockselects specific request enables. Valid values are are a logical OR of the following values:
  • CS_ACLK,
  • CS_HSMCLK,
  • CS_SMCLK,
  • CS_MCLK
Returns
NONE

References ASSERT, CS_ACLK, CS_HSMCLK, CS_KEY, CS_MCLK, and CS_SMCLK.

void CS_disableClockRequest ( uint32_t  selectClock)

Disables conditional module requests

Parameters
selectClockselects specific request disables. Valid values are are a logical OR of the following values:
  • CS_ACLK,
  • CS_HSMCLK,
  • CS_SMCLK,
  • CS_MCLK
Returns
NONE

References ASSERT, CS_ACLK, CS_HSMCLK, CS_KEY, CS_MCLK, and CS_SMCLK.

uint32_t CS_getACLK ( void  )

Get the current ACLK frequency.

If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CS_setExternalClockSourceFrequency() API was invoked before in case LFXT is being used.

Returns
Current ACLK frequency in Hz

References CS_ACLK_DIV_BITPOS, and CS_ACLK_SRC_BITPOS.

uint32_t CS_getSMCLK ( void  )

Get the current SMCLK frequency.

If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CS_setExternalClockSourceFrequency API was invoked before in case LFXT or HFXT is being used.

Returns
Current SMCLK frequency in Hz

References CS_HSMCLK_SRC_BITPOS.

uint32_t CS_getMCLK ( void  )

Get the current MCLK frequency.

If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CS_setExternalClockSourceFrequency API was invoked before in case LFXT or HFXT is being used.

Returns
Current MCLK frequency in Hz

References CS_MCLK_DIV_BITPOS, and CS_MCLK_SRC_BITPOS.

uint32_t CS_getBCLK ( void  )

Get the current BCLK frequency.

If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CS_setExternalClockSourceFrequency API was invoked before in case LFXT or HFXT is being used.

Returns
Current BCLK frequency in Hz

References CS_CLOCK_DIVIDER_1, CS_LFXTCLK_SELECT, and CS_REFOCLK_SELECT.

uint32_t CS_getHSMCLK ( void  )

Get the current HSMCLK frequency.

If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CS_setExternalClockSourceFrequency API was invoked before in case LFXT or HFXT is being used.

Returns
Current HSMCLK frequency in Hz

References CS_HSMCLK_DIV_BITPOS, and CS_HSMCLK_SRC_BITPOS.

void CS_setDCOCenteredFrequency ( uint32_t  dcoFreq)

Sets the centered frequency of DCO operation. Each frequency represents the centred frequency of a particular frequency range. Further tuning can be achieved by using the CS_tuneDCOFrequency function. Note that setting the nominal frequency will reset the tuning parameters.

Parameters
dcoFreqselects between the valid frequencies:
  • CS_DCO_FREQUENCY_1_5, [1MHz to 2MHz]
  • CS_DCO_FREQUENCY_3, [2MHz to 4MHz]
  • CS_DCO_FREQUENCY_6, [4MHz to 8MHz]
  • CS_DCO_FREQUENCY_12, [8MHz to 16MHz]
  • CS_DCO_FREQUENCY_24, [16MHz to 32MHz]
  • CS_DCO_FREQUENCY_48 [32MHz to 64MHz]
Returns
NONE

References ASSERT, CS_DCO_FREQUENCY_12, CS_DCO_FREQUENCY_1_5, CS_DCO_FREQUENCY_24, CS_DCO_FREQUENCY_3, CS_DCO_FREQUENCY_48, CS_DCO_FREQUENCY_6, and CS_KEY.

Referenced by CS_setDCOFrequency().

void CS_setDCOFrequency ( uint32_t  dcoFrequency)

Automatically sets/tunes the DCO to the given frequency. Any valid value up to max frequency in the spec can be given to this function and the API will do its best to determine the correct tuning parameter.

Note
The frequency ranges that can be custom tuned on early release MSP432 devices is limited. For further details on supported tunable frequencies, please refer to the device errata sheet or data sheet.
Parameters
dcoFrequencyFrequency in Hz that the user wants to set the DCO to.
Note
This function uses floating point math to calculate the DCO tuning parameter. If efficiency is a concern, the user should use the FPU_enableModule function (if available) to enable the floating point co-processor.
Returns
None

Automatically sets/tunes the DCO to the given frequency. Any valid value up to (and including) 64Mhz can be given to this function and the API will do its best to determine the correct tuning parameter.

Note
This function is not currently available on pre-release MSP432 devices. On early release versions of MSP432, the DCO calibration information has not been populated making the DCO only able to operate at the pre-calibrated centered frequencies accessible by the CS_setDCOCenteredFrequency function. While this function will be added on the final devices being released, for early silicon please default to the pre-calibrated DCO center frequencies.
Parameters
dcoFrequencyFrequency in Hz (1500000 - 64000000) that the user wants to set the DCO to.
Note
This function uses floating point math to calculate the DCO tuning parameter. If efficiency is a concern, the user should use the FPU_enableModule function (if available) to enable the floating point co-processor.
Returns
None

References ASSERT, CS_12MHZ, CS_15MHZ, CS_24MHZ, CS_3MHZ, CS_48MHZ, CS_6MHZ, CS_DCO_FREQUENCY_12, CS_DCO_FREQUENCY_1_5, CS_DCO_FREQUENCY_24, CS_DCO_FREQUENCY_3, CS_DCO_FREQUENCY_48, CS_DCO_FREQUENCY_6, CS_setDCOCenteredFrequency(), CS_tuneDCOFrequency(), DEVICE_PG1_1, SysCtl_CSCalTLV_Info::rDCOER_CONSTK_RSEL04, SysCtl_CSCalTLV_Info::rDCOER_CONSTK_RSEL5, SysCtl_CSCalTLV_Info::rDCOER_FCAL_RSEL04, SysCtl_CSCalTLV_Info::rDCOER_FCAL_RSEL5, SysCtl_CSCalTLV_Info::rDCOIR_CONSTK_RSEL04, SysCtl_CSCalTLV_Info::rDCOIR_CONSTK_RSEL5, SysCtl_CSCalTLV_Info::rDCOIR_FCAL_RSEL04, SysCtl_CSCalTLV_Info::rDCOIR_FCAL_RSEL5, SysCtl_getTLVInfo(), and TLV_TAG_CS.

void CS_tuneDCOFrequency ( int16_t  tuneParameter)

Tunes the DCO to a specific frequency. Tuning of the DCO is based off of the following equation in the user's guide:

See the user's guide for more detailed information about DCO tuning.

Note
This function is not currently available on pre-release MSP432 devices. On early release versions of MSP432, the DCO calibration information has not been populated making the DCO only able to operate at the pre-calibrated centered frequencies accessible by the CS_setDCOCenteredFrequency function. While this function will be added on the final devices being released, for early silicon please default to the pre-calibrated DCO center frequencies.
Parameters
tuneParameterTuning parameter in 2's Compliment representation. Can be negative or positive.
Returns
NONE

References CS_KEY, and DEVICE_PG1_1.

Referenced by CS_setDCOFrequency().

void CS_enableDCOExternalResistor ( void  )

Enables the external resistor for DCO operation

Returns
NONE

References CS_KEY.

void CS_disableDCOExternalResistor ( void  )

Disables the external resistor for DCO operation

Returns
NONE

References CS_KEY.

void CS_setDCOExternalResistorCalibration ( uint_fast8_t  uiCalData,
uint_fast8_t  freqRange 
)

Sets the calibration value for the DCO when using the external resistor mode. This value is used for tuning the DCO to custom frequencies. By default, the value in the CS module is populated by the calibration data of the suggested external resistor (see device datasheet).

Parameters
calDatais the calibration data constant for the external resistor.
freqRangeis the range of the DCO to set the external calibration for. Frequencies above 32MHZ have a different calibration value than frequencies below 32MHZ.
Returns
None

References CS_KEY, CS_OVER32MHZ, and DEVICE_PG1_1.

uint32_t CS_getDCOFrequency ( void  )

Gets the current tuned DCO frequency. If no tuning has been done, this returns the nominal DCO frequency of the current DCO range. Note that this function will grab any constant/calibration data from the DDDS table without any user interaction needed.

Note
This function uses floating point math to calculate the DCO tuning parameter. If efficiency is a concern, the user should use the FPU_enableModule function (if available) to enable the floating point co-processor.
Returns
Current DCO frequency in Hz

References DEVICE_PG1_1, SysCtl_CSCalTLV_Info::rDCOER_CONSTK_RSEL04, SysCtl_CSCalTLV_Info::rDCOER_CONSTK_RSEL5, SysCtl_CSCalTLV_Info::rDCOER_FCAL_RSEL04, SysCtl_CSCalTLV_Info::rDCOER_FCAL_RSEL5, SysCtl_CSCalTLV_Info::rDCOIR_CONSTK_RSEL04, SysCtl_CSCalTLV_Info::rDCOIR_CONSTK_RSEL5, SysCtl_CSCalTLV_Info::rDCOIR_FCAL_RSEL04, SysCtl_CSCalTLV_Info::rDCOIR_FCAL_RSEL5, SysCtl_getTLVInfo(), and TLV_TAG_CS.

void CS_enableFaultCounter ( uint_fast8_t  counterSelect)

Enables the fault counter for the CS module. This function can enable either the HFXT fault counter or the LFXT fault counter.

Parameters
counterSelectselects the fault counter to enable
  • CS_HFXT_FAULT_COUNTER
  • CS_LFXT_FAULT_COUNTER
Returns
NONE

References ASSERT, CS_HFXT_FAULT_COUNTER, and CS_KEY.

void CS_disableFaultCounter ( uint_fast8_t  counterSelect)

Disables the fault counter for the CS module. This function can disable either the HFXT fault counter or the LFXT fault counter.

Parameters
counterSelectselects the fault counter to disable
  • CS_HFXT_FAULT_COUNTER
  • CS_LFXT_FAULT_COUNTER
Returns
NONE

References ASSERT, CS_HFXT_FAULT_COUNTER, and CS_KEY.

void CS_resetFaultCounter ( uint_fast8_t  counterSelect)

Resets the fault counter for the CS module. This function can reset either the HFXT fault counter or the LFXT fault counter.

Parameters
counterSelectselects the fault counter to reset
  • CS_HFXT_FAULT_COUNTER
  • CS_LFXT_FAULT_COUNTER
Returns
NONE

References ASSERT, CS_HFXT_FAULT_COUNTER, and CS_KEY.

void CS_startFaultCounter ( uint_fast8_t  counterSelect,
uint_fast8_t  countValue 
)

Sets the count for the start value of the fault counter. This function can be used to set either the HFXT count or the LFXT count.

Parameters
counterSelectselects the fault counter to reset
  • CS_HFXT_FAULT_COUNTER
  • CS_LFXT_FAULT_COUNTER
countValueselects the cycles to set the fault counter to
  • CS_FAULT_COUNTER_4096_CYCLES
  • CS_FAULT_COUNTER_8192_CYCLES
  • CS_FAULT_COUNTER_16384_CYCLES
  • CS_FAULT_COUNTER_32768_CYCLES
Returns
NONE

References ASSERT, CS_FAULT_COUNTER_16384_CYCLES, CS_FAULT_COUNTER_32768_CYCLES, CS_FAULT_COUNTER_4096_CYCLES, CS_FAULT_COUNTER_8192_CYCLES, CS_HFXT_FAULT_COUNTER, and CS_KEY.

void CS_enableInterrupt ( uint32_t  flags)

Enables individual clock control interrupt sources.

Parameters
flagsis a bit mask of the interrupt sources to be enabled. Must be a logical OR of:
  • CS_LFXT_FAULT,
  • CS_HFXT_FAULT,
  • CS_DCOMIN_FAULT,
  • CS_DCOMAX_FAULT,
  • CS_DCO_OPEN_FAULT,
  • CS_STARTCOUNT_LFXT_FAULT,
  • CS_STARTCOUNT_HFXT_FAULT,

This function enables the indicated clock system interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Note
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
Returns
None.

References CS_KEY.

void CS_disableInterrupt ( uint32_t  flags)

Disables individual clock system interrupt sources.

Parameters
flagsis a bit mask of the interrupt sources to be disabled. Must be a logical OR of:
  • CS_LFXT_FAULT,
  • CS_HFXT_FAULT,
  • CS_DCOMIN_FAULT,
  • CS_DCOMAX_FAULT,
  • CS_DCO_OPEN_FAULT,
  • CS_STARTCOUNT_LFXT_FAULT,
  • CS_STARTCOUNT_HFXT_FAULT,
Note
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
Returns
None.

References CS_KEY.

uint32_t CS_getEnabledInterruptStatus ( void  )

Gets the current interrupt status masked with the enabled interrupts. This function is useful to call in ISRs to get a list of pending interrupts that are actually enabled and could have caused the ISR.

Returns
The current interrupt status, enumerated as a bit field of
  • CS_LFXT_FAULT,
  • CS_HFXT_FAULT,
  • CS_DCO_OPEN_FAULT,
  • CS_DCO_SHORT_FAULT,
  • CS_STARTCOUNT_LFXT_FAULT,
  • CS_STARTCOUNT_HFXT_FAULT,
Note
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.

References CS_getInterruptStatus().

uint32_t CS_getInterruptStatus ( void  )

Gets the current interrupt status.

Returns
The current interrupt status, enumerated as a bit field of:
  • CS_LFXT_FAULT,
  • CS_HFXT_FAULT,
  • CS_DCO_OPEN_FAULT,
  • CS_DCO_SHORT_FAULT,
  • CS_STARTCOUNT_LFXT_FAULT,
  • CS_STARTCOUNT_HFXT_FAULT,
Note
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.

Referenced by CS_getEnabledInterruptStatus().

void CS_clearInterruptFlag ( uint32_t  flags)

Clears clock system interrupt sources.

Parameters
flagsis a bit mask of the interrupt sources to be cleared. Must be a logical OR of:
  • CS_LFXT_FAULT,
  • CS_HFXT_FAULT,
  • CS_DCO_OPEN_FAULT,
  • CS_STARTCOUNT_LFXT_FAULT,
  • CS_STARTCOUNT_HFXT_FAULT,

The specified clock system interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep it from being called again immediately upon exit.

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
Returns
None.

References CS_KEY.

void CS_registerInterrupt ( void(*)(void)  intHandler)

Registers an interrupt handler for the clock system interrupt.

Parameters
intHandleris a pointer to the function to be called when the clock system interrupt occurs.

This function registers the handler to be called when a clock system interrupt occurs. This function enables the global interrupt in the interrupt controller; specific clock system interrupts must be enabled via CS_enableInterrupt(). It is the interrupt handler's responsibility to clear the interrupt source via CS_clearInterruptFlag().

Clock System can generate interrupts when

See also
Interrupt_registerInterrupt() for important information about registering interrupt handlers.
Returns
None.

References INT_CS, Interrupt_enableInterrupt(), and Interrupt_registerInterrupt().

void CS_unregisterInterrupt ( void  )

Unregisters the interrupt handler for the clock system.

This function unregisters the handler to be called when a clock system interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

See also
Interrupt_registerInterrupt() for important information about registering interrupt handlers.
Returns
None.

References INT_CS, Interrupt_disableInterrupt(), and Interrupt_unregisterInterrupt().


Copyright 2016, Texas Instruments Incorporated