Functions | Variables
cs.c File Reference
#include "inc/hw_types.h"
#include "driverlib/5xx_6xx/cs.h"
#include "deprecated/CCS/msp430xgeneric.h"
#include "driverlib/5xx_6xx/debug.h"
#include "inc/sfr_sys_baseAddress.h"

Functions

void CS_setExternalClockSource (unsigned int baseAddress, unsigned long XT1CLK_frequency, unsigned long XT2CLK_frequency)
void CS_clockSignalInit (unsigned int baseAddress, unsigned char selectedClockSignal, unsigned int clockSource, unsigned int clockSourceDivider)
void CS_XT1Start (unsigned int baseAddress, unsigned int xt1drive)
void CS_bypassXT1 (unsigned int baseAddress)
unsigned short CS_XT1StartWithTimeout (unsigned int baseAddress, unsigned int xt1drive, unsigned long timeout)
unsigned short CS_bypassXT1WithTimeout (unsigned int baseAddress, unsigned long timeout)
void CS_XT1Off (unsigned int baseAddress)
void CS_XT2Start (unsigned int baseAddress, unsigned int xt2drive)
void CS_bypassXT2 (unsigned int baseAddress)
unsigned short CS_XT2StartWithTimeout (unsigned int baseAddress, unsigned int xt2drive, unsigned long timeout)
unsigned short CS_bypassXT2WithTimeout (unsigned int baseAddress, unsigned long timeout)
void CS_XT2Off (unsigned int baseAddress)
void CS_enableClockRequest (unsigned int baseAddress, unsigned char selectClock)
void CS_disableClockRequest (unsigned int baseAddress, unsigned char selectClock)
unsigned char CS_faultFlagStatus (unsigned int baseAddress, unsigned char mask)
void CS_clearFaultFlag (unsigned int baseAddress, unsigned char mask)
unsigned long privateCSSourceClockFromDCO (unsigned int baseAddress, unsigned char clockdivider)
unsigned long privateCSComputeCLKFrequency (unsigned int baseAddress, unsigned int CLKSource, unsigned int CLKSourceDivider)
unsigned long CS_getACLK (unsigned int baseAddress)
unsigned long CS_getSMCLK (unsigned int baseAddress)
unsigned long CS_getMCLK (unsigned int baseAddress)
unsigned int CS_clearAllOscFlagsWithTimeout (unsigned int baseAddress, unsigned long timeout)
void CS_setDCOFreq (unsigned int baseAddress, unsigned int dcorsel, unsigned int dcofsel)

Variables

unsigned long CS_XT1ClockFrequency = 0
unsigned long CS_XT2ClockFrequency = 0

Function Documentation

void CS_setExternalClockSource ( unsigned int  baseAddress,
unsigned long  XT1CLK_frequency,
unsigned long  XT2CLK_frequency 
)

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 XT1Start, XT1ByPass, XT1StartWithTimeout, XT1ByPassWithTimeout.

Parameters:
baseAddressis the base address of the CS module.
XT1CLK_frequencyis the XT1 crystal frequencies in Hz
XT2CLK_frequencyis the XT2 crystal frequencies in Hz
Returns:
None

References CS_XT1ClockFrequency, and CS_XT2ClockFrequency.

void CS_clockSignalInit ( unsigned int  baseAddress,
unsigned char  selectedClockSignal,
unsigned int  clockSource,
unsigned int  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 MSP430ware documentation for CS module or Device Family User's Guide for details of default clock signal states. IMPORTANT: User must call CS_init function before calling this API. Otherwise CS register will remain with default values.

Parameters:
baseAddressis the base address of the CS module.
selectedClockSignal- Valid values are CS_ACLK, CS_MCLK, CS_SMCLK,
clockSourceis Clock source for the selectedClock Signal Valid values for FR57xx devices CS_XT1CLK_SELECT, CS_VLOCLK_SELECT, CS_DCOCLK_SELECT, CS_XT2CLK_SELECT Valid values for FR58xx/FR59xx devices CS_LFXTCLK_SELECT, CS_VLOCLK_SELECT, CS_DCOCLK_SELECT, [Not available for ACLK] CS_HFXTCLK_SELECT, [Not available for ACLK] CS_LFMODOSC_SELECT, CS_MODOSC_SELECT [Not available for ACLK]
clockSourceDivider- selected 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 registers are CSCTL0, CSCTL2, CSCTL3

Returns:
NONE

References ASSERT, CS_ACLK, CS_CLOCK_DIVIDER_1, CS_CLOCK_DIVIDER_16, CS_CLOCK_DIVIDER_2, CS_CLOCK_DIVIDER_32, CS_CLOCK_DIVIDER_4, CS_CLOCK_DIVIDER_8, CS_DCOCLK_SELECT, CS_MCLK, CS_MODOSC_SELECT, CS_SMCLK, CS_VLOCLK_SELECT, CS_XT1CLK_SELECT, CS_XT2CLK_SELECT, and HWREG.

void CS_XT1Start ( unsigned int  baseAddress,
unsigned int  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 is call.

Parameters:
baseAddressis the base address of the CS module.
xt1driveis the target drive strength for the XT1 crystal oscillator. Valid values: CS_XT1_DRIVE0, CS_XT1_DRIVE1, CS_XT1_DRIVE2, CS_XT1_DRIVE3. [Default]

Modified registers are CSCTL0, CSCTL4, CSCTL5 and SFRIFG1

Returns:
None

References ASSERT, CS_XT1_DRIVE0, CS_XT1_DRIVE1, CS_XT1_DRIVE2, CS_XT1_DRIVE3, CS_XT1ClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, and XT1_FREQUENCY_THRESHOLD.

void CS_bypassXT1 ( unsigned int  baseAddress)

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 this function is call.

Parameters:
baseAddressis the base address of the CS module.

Modified registers are CSCTL0, CSCTL4, CSCTL5, SFRIFG1

Returns:
None

References ASSERT, CS_XT1ClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, and XT1_FREQUENCY_THRESHOLD.

unsigned short CS_XT1StartWithTimeout ( unsigned int  baseAddress,
unsigned int  xt1drive,
unsigned long  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 is call.

Parameters:
baseAddressis the base address of the CS module.
xt1driveis the target drive strength for the XT1 crystal oscillator. Valid values are CS_XT1_DRIVE0, CS_XT1_DRIVE1, CS_XT1_DRIVE2, CS_XT1_DRIVE3 [Default Value]
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified registers are CSCTL0, CSCTL4, CSCTL5 and SFRIFG1

Returns:
STATUS_SUCCESS or STATUS_FAIL

References ASSERT, CS_XT1_DRIVE0, CS_XT1_DRIVE1, CS_XT1_DRIVE2, CS_XT1_DRIVE3, CS_XT1ClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, STATUS_SUCCESS, and XT1_FREQUENCY_THRESHOLD.

unsigned short CS_bypassXT1WithTimeout ( unsigned int  baseAddress,
unsigned long  timeout 
)

Bypasses the XT1 crystal oscillator with time out. 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:
baseAddressis the base address of the CS module.
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified registers are CSCTL0, CSCTL4, CSCTL5, SFRIFG1

Returns:
STATUS_SUCCESS or STATUS_FAIL

References ASSERT, CS_XT1ClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, STATUS_SUCCESS, and XT1_FREQUENCY_THRESHOLD.

void CS_XT1Off ( unsigned int  baseAddress)

Stops the XT1 oscillator using the XT1OFF bit.

Parameters:
baseAddressis the base address of the CS module.

Modified registers are CSCTL4

Returns:
NONE

References HWREG.

void CS_XT2Start ( unsigned int  baseAddress,
unsigned int  xt2drive 
)

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:
baseAddressis the base address of the CS module.
xt2driveis the target drive strength for the XT2 crystal oscillator. Valid values are CS_XT2DRIVE_4MHZ_8MHZ, CS_XT2DRIVE_8MHZ_16MHZ, CS_XT2DRIVE_16MHZ_24MHZ, CS_XT2DRIVE_24MHZ_32MHZ. [Default]

Modified registers are CSCTL4, CSCTL5, SFRIFG1

Returns:
NONE

References ASSERT, CS_XT2ClockFrequency, CS_XT2DRIVE_16MHZ_24MHZ, CS_XT2DRIVE_24MHZ_32MHZ, CS_XT2DRIVE_4MHZ_8MHZ, CS_XT2DRIVE_8MHZ_16MHZ, HWREG, HWREGB, and SFR_BASEADDRESS.

void CS_bypassXT2 ( unsigned int  baseAddress)

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.

Parameters:
baseAddressis the base address of the CS module.

Modified registers are CSCTL4, CSCTL5, SFRIFG1

Returns:
NONE

References ASSERT, CS_XT2ClockFrequency, HWREG, HWREGB, and SFR_BASEADDRESS.

unsigned short CS_XT2StartWithTimeout ( unsigned int  baseAddress,
unsigned int  xt2drive,
unsigned long  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:
baseAddressis the base address of the CS module.
xt2driveis the target drive strength for the XT2 crystal oscillator. Valid values are CS_XT2_4MHZ_8MHZ, CS_XT2_8MHZ_16MHZ, CS_XT2_16MHZ_24MHZ CS_XT2_24MHZ_32MHZ [Default Value]
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified registers are CSCTL4, CSCTL5, SFRIFG1

Returns:
STATUS_SUCCESS or STATUS_FAIL

References ASSERT, CS_XT2ClockFrequency, CS_XT2DRIVE_24MHZ_32MHZ, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.

unsigned short CS_bypassXT2WithTimeout ( unsigned int  baseAddress,
unsigned long  timeout 
)

Bypasses the XT2 crystal oscillator, 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:
baseAddressis the base address of the CS module.
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified registers are CSCTL4, CSCTL5, SFRIFG1G

Returns:
STATUS_SUCCESS or STATUS_FAIL

References ASSERT, CS_XT2ClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.

void CS_XT2Off ( unsigned int  baseAddress)

Stops the XT2 oscillator using the XT2OFF bit.

Parameters:
baseAddressis the base address of the CS module.

Modified registers are CSCTL4

Returns:
NONE

References HWREG.

void CS_enableClockRequest ( unsigned int  baseAddress,
unsigned char  selectClock 
)

Enables conditional module requests

Parameters:
baseAddressis the base address of the CS module.
selectClockselects specific request enables. Valid values are CS_ACLK, CS_SMCLK, CS_MCLK, CS_MODOSC

Modified registers are CSCTL6

Returns:
NONE

References ASSERT, CS_ACLK, CS_MCLK, CS_MODOSC, CS_SMCLK, and HWREGB.

void CS_disableClockRequest ( unsigned int  baseAddress,
unsigned char  selectClock 
)

Disables conditional module requests

Parameters:
baseAddressis the base address of the CS module.
selectClockselects specific request enables. Valid values are CS_ACLK, CS_SMCLK, CS_MCLK, CS_MODOSC

Modified registers are CSCTL6

Returns:
NONE

References ASSERT, CS_ACLK, CS_MCLK, CS_MODOSC, CS_SMCLK, and HWREGB.

unsigned char CS_faultFlagStatus ( unsigned int  baseAddress,
unsigned char  mask 
)

Gets the current CS fault flag status.

Parameters:
baseAddressis the base address of the CS module.
maskis the masked interrupt flag status to be returned. Mask parameter can be either any of the following selection.
  • CS_XT2OFFG - XT2 oscillator fault flag
  • CS_XT1OFFG - XT1 oscillator fault flag (HF mode) Modified registers are CSCTL5
Returns:
The current flag status for the corresponding masked bit

References ASSERT, CS_XT2OFFG, and HWREGB.

void CS_clearFaultFlag ( unsigned int  baseAddress,
unsigned char  mask 
)

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

Parameters:
baseAddressis the base address of the CS module.
maskis the masked interrupt flag status to be returned. mask parameter can be any one of the following
  • CS_XT2OFFG - XT2 oscillator fault flag
  • CS_XT1OFFG - XT1 oscillator fault flag (HF mode)

Modified registers are CSCTL5

Returns:
NONE

References ASSERT, CS_XT2OFFG, and HWREGB.

unsigned long privateCSSourceClockFromDCO ( unsigned int  baseAddress,
unsigned char  clockdivider 
)
unsigned long privateCSComputeCLKFrequency ( unsigned int  baseAddress,
unsigned int  CLKSource,
unsigned int  CLKSourceDivider 
)
unsigned long CS_getACLK ( unsigned int  baseAddress)

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. User must call CS_init before calling this function.

Parameters:
baseAddressis the base address of the CS module.
Returns:
Current ACLK frequency in Hz

References HWREG, and privateCSComputeCLKFrequency().

unsigned long CS_getSMCLK ( unsigned int  baseAddress)

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. User must call CS_init before calling this function.

Parameters:
baseAddressis the base address of the CS module.
Returns:
Current SMCLK frequency in Hz

References HWREG, HWREGB, and privateCSComputeCLKFrequency().

unsigned long CS_getMCLK ( unsigned int  baseAddress)

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. User must call CS_init before calling this function.

Parameters:
baseAddressis the base address of the CS module.
Returns:
Current MCLK frequency in Hz

References HWREG, and privateCSComputeCLKFrequency().

unsigned int CS_clearAllOscFlagsWithTimeout ( unsigned int  baseAddress,
unsigned long  timeout 
)

Clears all the Oscillator Flags

Parameters:
baseAddressis the base address of the CS module.
timeoutis the count value that gets decremented every time the loop that clears oscillator fault flags gets executed.

Modified registers are CSCTL5, SFRIFG1G

Returns:
the mask of the oscillator flag status.

References HWREGB, and SFR_BASEADDRESS.

void CS_setDCOFreq ( unsigned int  baseAddress,
unsigned int  dcorsel,
unsigned int  dcofsel 
)

Set DCO frequency

Before invoking the this function, the user must call CS_init.

Parameters:
baseAddressis the base address of the CS module.
dcofselselects valid frequency options based on dco frequency range selection (dcorsel). Valid options are: For FR57xx devices: CS_DCOFSEL_0 - Low frequency option 5.33MHZ. High frequency option 16MHz. CS_DCOFSEL_1 - Low frequency option 5.33MHZ. High frequency option 16MHz. CS_DCOFSEL_2 - Low frequency option 6.67MHZ. High frequency option 20MHz. CS_DCOFSEL_3 - Low frequency option 8MHZ. High frequency option 24MHz. [Default] For FR58xx/FR59xx devices: CS_DCOFSEL_0 - Low frequency option 1 MHZ. High frequency option 1 MHz. CS_DCOFSEL_1 - Low frequency option 2.67 MHZ. High frequency option 5.33 MHz. CS_DCOFSEL_2 Low frequency option 3.33 MHZ. High frequency option 6.67 MHz. CS_DCOFSEL_3 Low frequency option 4 MHZ. High frequency option 8 MHz. CS_DCOFSEL_4 Low frequency option 5.33 MHZ. High frequency option 16 MHz.
dcorselselects frequency range option. Valid options are: CS_DCORSEL_0 [Default] CS_DCORSEL_1
Returns:
NONE

References ASSERT, CS_DCOFSEL_0, CS_DCOFSEL_1, CS_DCOFSEL_2, CS_DCOFSEL_3, CS_DCORSEL_0, CS_DCORSEL_1, and HWREG.


Variable Documentation

unsigned long CS_XT1ClockFrequency = 0
unsigned long CS_XT2ClockFrequency = 0

Copyright 2012, Texas Instruments Incorporated