MSP430 DriverLib for MSP430FR5xx_6xx Devices  2.70.00.08
 All Data Structures Files Functions Variables Enumerations Modules Pages
cs

Macros

#define CS_DCO_FREQ_1   1000000
 
#define CS_DCO_FREQ_2   2670000
 
#define CS_DCO_FREQ_3   3330000
 
#define CS_DCO_FREQ_4   4000000
 
#define CS_DCO_FREQ_5   5330000
 
#define CS_DCO_FREQ_6   6670000
 
#define CS_DCO_FREQ_7   8000000
 
#define CS_DCO_FREQ_8   16000000
 
#define CS_DCO_FREQ_9   20000000
 
#define CS_DCO_FREQ_10   24000000
 
#define CS_VLOCLK_FREQUENCY   10000
 
#define CS_MODCLK_FREQUENCY   5000000
 
#define CS_LFMODCLK_FREQUENCY   39062
 
#define LFXT_FREQUENCY_THRESHOLD   50000
 

Functions

void CS_setExternalClockSource (uint32_t LFXTCLK_frequency, uint32_t HFXTCLK_frequency)
 Sets the external clock source. More...
 
void CS_initClockSignal (uint8_t selectedClockSignal, uint16_t clockSource, uint16_t clockSourceDivider)
 Initializes clock signal. More...
 
void CS_turnOnLFXT (uint16_t lfxtdrive)
 Initializes the LFXT crystal in low frequency mode. More...
 
void CS_turnOffSMCLK (void)
 Turns off SMCLK using the SMCLKOFF bit. More...
 
void CS_turnOnSMCLK (void)
 Turns on SMCLK using the SMCLKOFF bit. More...
 
void CS_bypassLFXT (void)
 Bypasses the LFXT crystal oscillator. More...
 
bool CS_turnOnLFXTWithTimeout (uint16_t lfxtdrive, uint32_t timeout)
 Initializes the LFXT crystal oscillator in low frequency mode with timeout. More...
 
bool CS_bypassLFXTWithTimeout (uint32_t timeout)
 Bypass the LFXT crystal oscillator with timeout. More...
 
void CS_turnOffLFXT (void)
 Stops the LFXT oscillator using the LFXTOFF bit. More...
 
void CS_turnOnHFXT (uint16_t hfxtdrive)
 Starts the HFXFT crystal. More...
 
void CS_bypassHFXT (void)
 Bypasses the HFXT crystal oscillator. More...
 
bool CS_turnOnHFXTWithTimeout (uint16_t hfxtdrive, uint32_t timeout)
 Initializes the HFXT crystal oscillator with timeout. More...
 
bool CS_bypassHFXTWithTimeout (uint32_t timeout)
 Bypasses the HFXT crystal oscillator with timeout. More...
 
void CS_turnOffHFXT (void)
 Stops the HFXT oscillator using the HFXTOFF bit. More...
 
void CS_enableClockRequest (uint8_t selectClock)
 Enables conditional module requests. More...
 
void CS_disableClockRequest (uint8_t selectClock)
 Disables conditional module requests. More...
 
uint8_t CS_getFaultFlagStatus (uint8_t mask)
 Gets the current CS fault flag status. More...
 
void CS_clearFaultFlag (uint8_t mask)
 Clears the current CS fault flag status for the masked bit. More...
 
uint32_t CS_getACLK (void)
 Get the current ACLK frequency. More...
 
uint32_t CS_getSMCLK (void)
 Get the current SMCLK frequency. More...
 
uint32_t CS_getMCLK (void)
 Get the current MCLK frequency. More...
 
void CS_turnOffVLO (void)
 Turns off VLO. More...
 
uint16_t CS_clearAllOscFlagsWithTimeout (uint32_t timeout)
 Clears all the Oscillator Flags. More...
 
void CS_setDCOFreq (uint16_t dcorsel, uint16_t dcofsel)
 Set DCO frequency. More...
 

Detailed Description

Function Documentation

void CS_bypassHFXT ( void  )

Bypasses the HFXT crystal oscillator.

Bypasses the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz. Loops until all oscillator fault flags are cleared, with no timeout.NOTE: User must call CS_setExternalClockSource to set frequency of external clocks before calling this function.

Modified bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG register.

Returns
None
bool CS_bypassHFXTWithTimeout ( uint32_t  timeout)

Bypasses the HFXT crystal oscillator with timeout.

Bypasses the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. NOTE: User must call CS_setExternalClockSource to set frequency of external clocks before calling this function.

Parameters
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG1 register.

Returns
STATUS_SUCCESS or STATUS_FAIL
void CS_bypassLFXT ( void  )

Bypasses the LFXT crystal oscillator.

Bypasses the LFXT crystal oscillator. Loops until all oscillator fault flags are cleared, with no timeout. IMPORTANT: User must call CS_setExternalClockSource function to set frequency of external clocks before calling this function.

Modified bits of CSCTL0 register, bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG register.

Returns
None
bool CS_bypassLFXTWithTimeout ( uint32_t  timeout)

Bypass the LFXT crystal oscillator with timeout.

Bypasses the LFXT crystal oscillator with timeout. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. NOTE: User must call CS_setExternalClockSource to set frequency of external clocks before calling this function.

Parameters
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified bits of CSCTL0 register, bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG register.

Returns
STATUS_SUCCESS or STATUS_FAIL
uint16_t CS_clearAllOscFlagsWithTimeout ( uint32_t  timeout)

Clears all the Oscillator Flags.

Parameters
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified bits of CSCTL5 register and bits of SFRIFG1 register.

Returns
the mask of the oscillator flag status
void CS_clearFaultFlag ( uint8_t  mask)

Clears the current CS fault flag status for the masked bit.

Parameters
maskis the masked interrupt flag status to be returned. mask parameter can be any one of the following Mask value is the logical OR of any of the following:
  • CS_LFXTOFFG - LFXT oscillator fault flag
  • CS_HFXTOFFG - HFXT oscillator fault flag

Modified bits of CSCTL5 register.

Returns
None
void CS_disableClockRequest ( uint8_t  selectClock)

Disables conditional module requests.

Parameters
selectClockselects specific request enables. Valid values are:
  • CS_ACLK
  • CS_MCLK
  • CS_SMCLK
  • CS_MODOSC

Modified bits of CSCTL6 register.

Returns
None
void CS_enableClockRequest ( uint8_t  selectClock)

Enables conditional module requests.

Parameters
selectClockselects specific request enables. Valid values are:
  • CS_ACLK
  • CS_MCLK
  • CS_SMCLK
  • CS_MODOSC

Modified bits of CSCTL6 register.

Returns
None
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_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used.

Returns
Current ACLK frequency in Hz
uint8_t CS_getFaultFlagStatus ( uint8_t  mask)

Gets the current CS fault flag status.

Parameters
maskis the masked interrupt flag status to be returned. Mask parameter can be either any of the following selection. Mask value is the logical OR of any of the following:
  • CS_LFXTOFFG - LFXT oscillator fault flag
  • CS_HFXTOFFG - HFXT oscillator fault flag
Returns
Logical OR of any of the following:
  • CS_LFXTOFFG LFXT oscillator fault flag
  • CS_HFXTOFFG HFXT oscillator fault flag
    indicating the status of the masked interrupts
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_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used.

Returns
Current MCLK frequency in Hz
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_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used.

Returns
Current SMCLK frequency in Hz
void CS_initClockSignal ( uint8_t  selectedClockSignal,
uint16_t  clockSource,
uint16_t  clockSourceDivider 
)

Initializes clock signal.

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 MSP430ware documentation for CS module or Device Family User's Guide for details of default clock signal states.

Parameters
selectedClockSignalSelected clock signal Valid values are:
  • CS_ACLK
  • CS_MCLK
  • CS_SMCLK
  • CS_MODOSC
clockSourceis the selected clock signal Valid values are:
  • CS_VLOCLK_SELECT
  • CS_DCOCLK_SELECT - [Not available for ACLK]
  • CS_LFXTCLK_SELECT
  • CS_HFXTCLK_SELECT - [Not available for ACLK]
  • CS_LFMODOSC_SELECT
  • CS_MODOSC_SELECT - [Not available for ACLK]
clockSourceDivideris the selected clock divider to calculate clock signal from clock source. Valid values are:
  • CS_CLOCK_DIVIDER_1 - [Default for ACLK]
  • CS_CLOCK_DIVIDER_2
  • CS_CLOCK_DIVIDER_4
  • CS_CLOCK_DIVIDER_8 - [Default for SMCLK and MCLK]
  • CS_CLOCK_DIVIDER_16
  • CS_CLOCK_DIVIDER_32

Modified bits of CSCTL0 register, bits of CSCTL3 register and bits of CSCTL2 register.

Returns
None
void CS_setDCOFreq ( uint16_t  dcorsel,
uint16_t  dcofsel 
)

Set DCO frequency.

Parameters
dcorselselects frequency range option. Valid values are:
  • CS_DCORSEL_0 [Default] - Low Frequency Option
  • CS_DCORSEL_1 - High Frequency Option
dcofselselects valid frequency options based on dco frequency range selection (dcorsel) Valid values are:
  • CS_DCOFSEL_0 - Low frequency option 1MHz. High frequency option 1MHz.
  • CS_DCOFSEL_1 - Low frequency option 2.67MHz. High frequency option 5.33MHz.
  • CS_DCOFSEL_2 - Low frequency option 3.33MHz. High frequency option 6.67MHz.
  • CS_DCOFSEL_3 - Low frequency option 4MHz. High frequency option 8MHz.
  • CS_DCOFSEL_4 - Low frequency option 5.33MHz. High frequency option 16MHz.
  • CS_DCOFSEL_5 - Low frequency option 6.67MHz. High frequency option 20MHz.
  • CS_DCOFSEL_6 - Low frequency option 8MHz. High frequency option 24MHz.
Returns
None
void CS_setExternalClockSource ( uint32_t  LFXTCLK_frequency,
uint32_t  HFXTCLK_frequency 
)

Sets the external clock source.

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_getMCLK, CS_getSMCLK, CS_getACLK and CS_turnOnLFXT, CS_LFXTByPass, CS_turnOnLFXTWithTimeout, CS_LFXTByPassWithTimeout, CS_turnOnHFXT, CS_HFXTByPass, CS_turnOnHFXTWithTimeout, CS_HFXTByPassWithTimeout.

Parameters
LFXTCLK_frequencyis the LFXT crystal frequencies in Hz
HFXTCLK_frequencyis the HFXT crystal frequencies in Hz
Returns
None
void CS_turnOffHFXT ( void  )

Stops the HFXT oscillator using the HFXTOFF bit.

Modified bits of CSCTL4 register.

Returns
None
void CS_turnOffLFXT ( void  )

Stops the LFXT oscillator using the LFXTOFF bit.

Modified bits of CSCTL4 register.

Returns
None
void CS_turnOffSMCLK ( void  )

Turns off SMCLK using the SMCLKOFF bit.

Modified bits of CSCTL4 register.

Returns
None
void CS_turnOffVLO ( void  )

Turns off VLO.

Modified bits of CSCTL4 register.

Returns
None
void CS_turnOnHFXT ( uint16_t  hfxtdrive)

Starts the HFXFT crystal.

Initializes the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 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_setExternalClockSource to set frequency of external clocks before calling this function.

Parameters
hfxtdriveis the target drive strength for the HFXT crystal oscillator. Valid values are:
  • CS_HFXT_DRIVE_4MHZ_8MHZ
  • CS_HFXT_DRIVE_8MHZ_16MHZ
  • CS_HFXT_DRIVE_16MHZ_24MHZ
  • CS_HFXT_DRIVE_24MHZ_32MHZ [Default]

Modified bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG1 register.

Returns
None
bool CS_turnOnHFXTWithTimeout ( uint16_t  hfxtdrive,
uint32_t  timeout 
)

Initializes the HFXT crystal oscillator with timeout.

Initializes the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CS_setExternalClockSource to set frequency of external clocks before calling this function.

Parameters
hfxtdriveis the target drive strength for the HFXT crystal oscillator. Valid values are:
  • CS_HFXT_DRIVE_4MHZ_8MHZ
  • CS_HFXT_DRIVE_8MHZ_16MHZ
  • CS_HFXT_DRIVE_16MHZ_24MHZ
  • CS_HFXT_DRIVE_24MHZ_32MHZ [Default]
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG1 register.

Returns
STATUS_SUCCESS or STATUS_FAIL
void CS_turnOnLFXT ( uint16_t  lfxtdrive)

Initializes the LFXT crystal in low frequency mode.

Initializes the LFXT crystal oscillator in low frequency mode. Loops until all oscillator fault flags are cleared, with no timeout. See the device- specific data sheet for appropriate drive settings. IMPORTANT: User must call CS_setExternalClockSource function to set frequency of external clocks before calling this function.

Parameters
lfxtdriveis the target drive strength for the LFXT crystal oscillator. Valid values are:
  • CS_LFXT_DRIVE_0
  • CS_LFXT_DRIVE_1
  • CS_LFXT_DRIVE_2
  • CS_LFXT_DRIVE_3 [Default]

Modified bits of CSCTL0 register, bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG1 register.

Returns
None
bool CS_turnOnLFXTWithTimeout ( uint16_t  lfxtdrive,
uint32_t  timeout 
)

Initializes the LFXT crystal oscillator in low frequency mode with timeout.

Initializes the LFXT crystal oscillator in low frequency mode with timeout. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. See the device-specific datasheet for appropriate drive settings. IMPORTANT: User must call CS_setExternalClockSource to set frequency of external clocks before calling this function.

Parameters
lfxtdriveis the target drive strength for the LFXT crystal oscillator. Valid values are:
  • CS_LFXT_DRIVE_0
  • CS_LFXT_DRIVE_1
  • CS_LFXT_DRIVE_2
  • CS_LFXT_DRIVE_3 [Default]
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified bits of CSCTL0 register, bits of CSCTL5 register, bits of CSCTL4 register and bits of SFRIFG1 register.

Returns
STATUS_SUCCESS or STATUS_FAIL indicating if the LFXT crystal oscillator was initialized successfully
void CS_turnOnSMCLK ( void  )

Turns on SMCLK using the SMCLKOFF bit.

Modified bits of CSCTL4 register.

Returns
None

Copyright 2016, Texas Instruments Incorporated