MSP430 DriverLib for MSP430FR57xx Devices  2.10.00.09
 All Data Structures Functions Variables Modules Pages
cs

Macros

#define CS_DCO_FREQ_1   5330000
 
#define CS_DCO_FREQ_2   6670000
 
#define CS_DCO_FREQ_3   8000000
 
#define CS_DCO_FREQ_4   16000000
 
#define CS_DCO_FREQ_5   20000000
 
#define CS_DCO_FREQ_6   24000000
 
#define CS_VLOCLK_FREQUENCY   10000
 
#define CS_MODCLK_FREQUENCY   5000000
 
#define CS_LFMODCLK_FREQUENCY   39062
 
#define XT1_FREQUENCY_THRESHOLD   50000
 

Functions

void CS_setExternalClockSource (uint32_t XT1CLK_frequency, uint32_t XT2CLK_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_turnOnXT1 (uint16_t xt1drive)
 Initializes the XT1 crystal oscillator in low frequency mode. More...
 
void CS_bypassXT1 (void)
 Bypasses the XT1 crystal oscillator. More...
 
bool CS_turnOnXT1WithTimeout (uint16_t xt1drive, uint32_t timeout)
 Initializes the XT1 crystal oscillator in low frequency mode with timeout. More...
 
bool CS_bypassXT1WithTimeout (uint32_t timeout)
 Bypasses the XT1 crystal oscillator with timeout. More...
 
void CS_turnOffXT1 (void)
 Stops the XT1 oscillator using the XT1OFF bit. More...
 
void CS_turnOnXT2 (uint16_t xt2drive)
 Starts the XT2 crystal. More...
 
void CS_bypassXT2 (void)
 Bypasses the XT2 crystal oscillator. More...
 
bool CS_turnOnXT2WithTimeout (uint16_t xt2drive, uint32_t timeout)
 Initializes the XT2 crystal oscillator with timeout. More...
 
bool CS_bypassXT2WithTimeout (uint32_t timeout)
 Bypasses the XT2 crystal oscillator with timeout. More...
 
void CS_turnOffXT2 (void)
 Stops the XT2 oscillator using the XT2OFF 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...
 
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_bypassXT1 ( void  )

Bypasses the XT1 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_bypassXT1WithTimeout ( uint32_t  timeout)

Bypasses the XT1 crystal oscillator with timeout.

Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero.IMPORTANT: 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
void CS_bypassXT2 ( void  )

Bypasses the XT2 crystal oscillator.

Bypasses the XT2 crystal oscillator which supports crystal frequencies between 4 MHz and 32 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_bypassXT2WithTimeout ( uint32_t  timeout)

Bypasses the XT2 crystal oscillator with timeout.

Bypasses the XT2 crystal oscillator with timeout, which supports crystal frequencies between 4 MHz and 32 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
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 value is the logical OR of any of the following:
  • CS_XT2OFFG - XT2 oscillator fault flag
  • CS_XT1OFFG - XT2 oscillator fault flag (HF mode)

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 XT1 or XT2 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 value is the logical OR of any of the following:
  • CS_XT2OFFG - XT2 oscillator fault flag
  • CS_XT1OFFG - XT2 oscillator fault flag (HF mode)
Returns
Logical OR of any of the following:
  • CS_XT2OFFG XT2 oscillator fault flag
  • CS_XT1OFFG XT2 oscillator fault flag (HF mode)
    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 XT1 or XT2 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 XT1 or XT2 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
selectedClockSignalis the selected clock signal Valid values are:
  • CS_ACLK
  • CS_MCLK
  • CS_SMCLK
  • CS_MODOSC
clockSourceis Clock source for the selectedClock Valid values are:
  • CS_XT1CLK_SELECT
  • CS_VLOCLK_SELECT
  • CS_DCOCLK_SELECT
  • CS_XT2CLK_SELECT
clockSourceDividerselects the 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 options are: CS_DCORSEL_0 [Default] CS_DCORSEL_1 Valid values are:
  • CS_DCORSEL_0
  • CS_DCORSEL_1
dcofselselects valid frequency options based on dco frequency range selection (dcorsel). Valid values are:
  • CS_DCOFSEL_0 - Low frequency option 5.33MHZ. High frequency option 16MHz.
  • CS_DCOFSEL_1 - Low frequency option 6.67MHZ. High frequency option 20MHz.
  • CS_DCOFSEL_2 - Low frequency option 5.33MHZ. High frequency option 16MHz.
  • CS_DCOFSEL_3 [Default] - Low frequency option 8MHZ. High frequency option 24MHz.
Returns
None
void CS_setExternalClockSource ( uint32_t  XT1CLK_frequency,
uint32_t  XT2CLK_frequency 
)

Sets the external clock source.

This function sets the external clock sources XT1 and XT2 crystal oscillator frequency values. This function must be called if an external crystal XT1 or XT2 is used and the user intends to call CS_getMCLK, CS_getSMCLK, CS_getACLK and turnOnXT1, XT1ByPass, turnOnXT1WithTimeout, XT1ByPassWithTimeout.

Parameters
XT1CLK_frequencyis the XT1 crystal frequencies in Hz
XT2CLK_frequencyis the XT2 crystal frequencies in Hz
Returns
None
void CS_turnOffXT1 ( void  )

Stops the XT1 oscillator using the XT1OFF bit.

Modified bits of CSCTL4 register.

Returns
None
void CS_turnOffXT2 ( void  )

Stops the XT2 oscillator using the XT2OFF bit.

Modified bits of CSCTL4 register.

Returns
None
void CS_turnOnXT1 ( uint16_t  xt1drive)

Initializes the XT1 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
xt1driveis the target drive strength for the XT1 crystal oscillator. Valid values are:
  • CS_XT1_DRIVE_0
  • CS_XT1_DRIVE_1
  • CS_XT1_DRIVE_2
  • CS_XT1_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_turnOnXT1WithTimeout ( uint16_t  xt1drive,
uint32_t  timeout 
)

Initializes the XT1 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 function to set frequency of external clocks before calling this function.

Parameters
xt1driveis the target drive strength for the XT1 crystal oscillator. Valid values are:
  • CS_XT1_DRIVE_0
  • CS_XT1_DRIVE_1
  • CS_XT1_DRIVE_2
  • CS_XT1_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
void CS_turnOnXT2 ( uint16_t  xt2drive)

Starts the XT2 crystal.

Initializes the XT2 crystal oscillator, which supports crystal frequencies between 4 MHz and 32 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
xt2driveis the target drive strength for the XT2 crystal oscillator. Valid values are:
  • CS_XT2_DRIVE_4MHZ_8MHZ
  • CS_XT2_DRIVE_8MHZ_16MHZ
  • CS_XT2_DRIVE_16MHZ_24MHZ
  • CS_XT2_DRIVE_24MHZ_32MHZ [Default]

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

Returns
None
bool CS_turnOnXT2WithTimeout ( uint16_t  xt2drive,
uint32_t  timeout 
)

Initializes the XT2 crystal oscillator with timeout.

Initializes the XT2 crystal oscillator, which supports crystal frequencies between 4 MHz and 32 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
xt2driveis the target drive strength for the XT2 crystal oscillator. Valid values are:
  • CS_XT2_DRIVE_4MHZ_8MHZ
  • CS_XT2_DRIVE_8MHZ_16MHZ
  • CS_XT2_DRIVE_16MHZ_24MHZ
  • CS_XT2_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

Copyright 2015, Texas Instruments Incorporated