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

Functions

void CSA_setExternalClockSource (unsigned int baseAddress, unsigned long LFXTCLK_frequency, unsigned long HFXTCLK_frequency)
void CSA_clockSignalInit (unsigned int baseAddress, unsigned char selectedClockSignal, unsigned int clockSource, unsigned int clockSourceDivider)
void CSA_LFXTStart (unsigned int baseAddress, unsigned int lfxtdrive)
void CSA_bypassLFXT (unsigned int baseAddress)
unsigned short CSA_LFXTStartWithTimeout (unsigned int baseAddress, unsigned int lfxtdrive, unsigned long timeout)
unsigned short CSA_bypassLFXTWithTimeout (unsigned int baseAddress, unsigned long timeout)
void CSA_LFXTOff (unsigned int baseAddress)
void CSA_HFXTStart (unsigned int baseAddress, unsigned int hfxtdrive)
void CSA_bypassHFXT (unsigned int baseAddress)
unsigned short CSA_HFXTStartWithTimeout (unsigned int baseAddress, unsigned int hfxtdrive, unsigned long timeout)
unsigned short CSA_bypassHFXTWithTimeout (unsigned int baseAddress, unsigned long timeout)
void CSA_HFXTOff (unsigned int baseAddress)
void CSA_enableClockRequest (unsigned int baseAddress, unsigned char selectClock)
void CSA_disableClockRequest (unsigned int baseAddress, unsigned char selectClock)
unsigned char CSA_faultFlagStatus (unsigned int baseAddress, unsigned char mask)
void CSA_clearFaultFlag (unsigned int baseAddress, unsigned char mask)
unsigned long privateCSASourceClockFromDCO (unsigned int baseAddress, unsigned char clockdivider)
unsigned long privateCSAComputeCLKFrequency (unsigned int baseAddress, unsigned int CLKSource, unsigned int CLKSourceDivider)
unsigned long CSA_getACLK (unsigned int baseAddress)
unsigned long CSA_getSMCLK (unsigned int baseAddress)
unsigned long CSA_getMCLK (unsigned int baseAddress)
void CSA_VLOoff (unsigned int baseAddress)
unsigned int CSA_clearAllOscFlagsWithTimeout (unsigned int baseAddress, unsigned long timeout)
void CSA_setDCOFreq (unsigned int baseAddress, unsigned int dcorsel, unsigned int dcofsel)

Variables

unsigned long CSA_LFXTClockFrequency = 0
unsigned long CSA_HFXTClockFrequency = 0

Function Documentation

void CSA_setExternalClockSource ( unsigned int  baseAddress,
unsigned long  LFXTCLK_frequency,
unsigned long  HFXTCLK_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 CSA_getMCLK, CSA_getSMCLK, CSA_getACLK and CSA_LFXTStart, CSA_LFXTByPass, CSA_LFXTStartWithTimeout, CSA_LFXTByPassWithTimeout, CSA_HFXTStart, CSA_HFXTByPass, CSA_HFXTStartWithTimeout, CSA_HFXTByPassWithTimeout.

Parameters:
baseAddressis the base address of the CSA module.
LFXTCLK_frequencyis the LFXT crystal frequencies in Hz
HFXTCLK_frequencyis the HFXT crystal frequencies in Hz
Returns:
None

References CSA_HFXTClockFrequency, and CSA_LFXTClockFrequency.

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

Parameters:
baseAddressis the base address of the CSA module.
selectedClockSignal- Valid values are CSA_ACLK, CSA_MCLK, CSA_SMCLK,
clockSourceis Clock source for the selectedClock Signal CSA_LFXTCLK_SELECT, CSA_VLOCLK_SELECT, CSA_DCOCLK_SELECT, [Not available for ACLK] CSA_HFXTCLK_SELECT, [Not available for ACLK] CSA_LFMODOSC_SELECT, CSA_MODOSC_SELECT [Not available for ACLK]
clockSourceDivider- selected the clock divider to calculate clock signal from clock source. Valid values are CSA_CLOCK_DIVIDER_1, [Default for ACLK] CSA_CLOCK_DIVIDER_2, CSA_CLOCK_DIVIDER_4, CSA_CLOCK_DIVIDER_8, [Default for SMCLK and MCLK] CSA_CLOCK_DIVIDER_16, CSA_CLOCK_DIVIDER_32

Modified registers are CSCTL0, CSCTL2, CSCTL3

Returns:
NONE

References ASSERT, CSA_ACLK, CSA_CLOCK_DIVIDER_1, CSA_CLOCK_DIVIDER_16, CSA_CLOCK_DIVIDER_2, CSA_CLOCK_DIVIDER_32, CSA_CLOCK_DIVIDER_4, CSA_CLOCK_DIVIDER_8, CSA_DCOCLK_SELECT, CSA_HFXTCLK_SELECT, CSA_LFMODOSC_SELECT, CSA_LFXTCLK_SELECT, CSA_MCLK, CSA_MODOSC_SELECT, CSA_SMCLK, CSA_VLOCLK_SELECT, and HWREG.

void CSA_LFXTStart ( unsigned int  baseAddress,
unsigned int  lfxtdrive 
)

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 CSA_setExternalClockSource function to set frequency of external clocks this function is call.

Parameters:
baseAddressis the base address of the CS module.
lfxtdriveis the target drive strength for the LFXT crystal oscillator. Valid values: CSA_LFXT_DRIVE0, CSA_LFXT_DRIVE1, CSA_LFXT_DRIVE2, CSA_LFXT_DRIVE3. [Default] Modified registers are CSCTL0, CSCTL4, CSCTL5 and SFRIFG1
Returns:
None

References ASSERT, CSA_LFXT_DRIVE0, CSA_LFXT_DRIVE1, CSA_LFXT_DRIVE2, CSA_LFXT_DRIVE3, CSA_LFXTClockFrequency, HWREG, HWREGB, and SFR_BASEADDRESS.

void CSA_bypassLFXT ( unsigned int  baseAddress)

Bypasses the LFXT crystal oscillator. Loops until all oscillator fault flags are cleared, with no timeout. IMPORTANT: User must call CSA_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, CSA_LFXTClockFrequency, HWREG, HWREGB, LFXT_FREQUENCY_THRESHOLD, and SFR_BASEADDRESS.

unsigned short CSA_LFXTStartWithTimeout ( unsigned int  baseAddress,
unsigned int  lfxtdrive,
unsigned long  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 CSA_setExternalClockSource to set frequency of external clocks before calling this function

Parameters:
baseAddressis the base address of the CS module.
lfxtdriveis the target drive strength for the LFXT crystal oscillator. Valid values are CSA_LFXTDRIVE0, CSA_LFXTDRIVE1, CSA_LFXTDRIVE2, CSA_LFXTDRIVE3. [Default]
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:
None

References ASSERT, CSA_LFXT_DRIVE0, CSA_LFXT_DRIVE1, CSA_LFXT_DRIVE2, CSA_LFXT_DRIVE3, CSA_LFXTClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.

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

Bypasses the LFXT crystal oscillator with time out. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. NOTE: User must call CSA_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, CSA_LFXTClockFrequency, HWREG, HWREGB, LFXT_FREQUENCY_THRESHOLD, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.

void CSA_LFXTOff ( unsigned int  baseAddress)

Stops the LFXT oscillator using the LFXTOFF bit.

Parameters:
baseAddressis the base address of the CS module.

Modified registers are CSCTL4

Returns:
NONE

References HWREG.

void CSA_HFXTStart ( unsigned int  baseAddress,
unsigned int  hfxtdrive 
)

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

Parameters:
baseAddressis the base address of the CS module.
hfxtdriveis the target drive strength for the HFXT crystal oscillator. Valid values are CSA_HFXTDRIVE_0, CSA_HFXTDRIVE_1, CSA_HFXTDRIVE_2, CSA_HFXTDRIVE_3 [Default]

Modified registers are CSCTL4, CSCTL5, SFRIFG1

Returns:
NONE

References ASSERT, CSA_HFXTClockFrequency, CSA_HFXTDRIVE_16MHZ_24MHZ, CSA_HFXTDRIVE_24MHZ_32MHZ, CSA_HFXTDRIVE_4MHZ_8MHZ, CSA_HFXTDRIVE_8MHZ_16MHZ, HWREG, HWREGB, and SFR_BASEADDRESS.

void CSA_bypassHFXT ( unsigned int  baseAddress)

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 CSA_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, CSA_HFXTClockFrequency, HWREG, HWREGB, and SFR_BASEADDRESS.

unsigned short CSA_HFXTStartWithTimeout ( unsigned int  baseAddress,
unsigned int  hfxtdrive,
unsigned long  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 CSA_setExternalClockSource to set frequency of external clocks before calling this function.

Parameters:
baseAddressis the base address of the CS module.
hfxtdriveis the target drive strength for the HFXT crystal oscillator. Valid values are CSA_HFXTDRIVE_0, CSA_HFXTDRIVE_1, CSA_HFXTDRIVE_2, CSA_HFXTDRIVE_3 [Default]
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, CSA_HFXTClockFrequency, CSA_HFXTDRIVE_24MHZ_32MHZ, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.

unsigned short CSA_bypassHFXTWithTimeout ( unsigned int  baseAddress,
unsigned long  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 CSA_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, CSA_HFXTClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.

void CSA_HFXTOff ( unsigned int  baseAddress)

Stops the HFXT oscillator using the HFXTOFF bit.

Parameters:
baseAddressis the base address of the CS module.

Modified registers are CSCTL4

Returns:
NONE

References CSA_HFXTOff().

Referenced by CSA_HFXTOff().

void CSA_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 CSA_ACLK, CSA_SMCLK, CSA_MCLK, CSA_MODOSC

Modified registers are CSCTL6

Returns:
NONE

References ASSERT, CSA_ACLK, CSA_MCLK, CSA_MODOSC, CSA_SMCLK, and HWREGB.

void CSA_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 CSA_ACLK, CSA_SMCLK, CSA_MCLK, CSA_MODOSC

Modified registers are CSCTL6

Returns:
NONE

References ASSERT, CSA_ACLK, CSA_MCLK, CSA_MODOSC, CSA_SMCLK, and HWREGB.

unsigned char CSA_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.
  • CSA_HFXTOFFG - HFXT oscillator fault flag
  • CSA_LFXTOFFG - LFXT oscillator fault flag Modified registers are CSCTL5
Returns:
The current flag status for the corresponding masked bit

References ASSERT, CSA_HFXTOFFG, CSA_LFXTOFFG, and HWREGB.

void CSA_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
  • CSA_HFXTOFFG - HFXT oscillator fault flag
  • CSA_LFXTOFFG - LFXT oscillator fault flag Modified registers are CSCTL5
Returns:
NONE

References ASSERT, CSA_HFXTOFFG, CSA_LFXTOFFG, and HWREGB.

unsigned long privateCSASourceClockFromDCO ( unsigned int  baseAddress,
unsigned char  clockdivider 
)
unsigned long privateCSAComputeCLKFrequency ( unsigned int  baseAddress,
unsigned int  CLKSource,
unsigned int  CLKSourceDivider 
)
unsigned long CSA_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 CSA_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used. User must call CSA_init before calling this function.

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

References HWREG, and privateCSAComputeCLKFrequency().

unsigned long CSA_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 CSA_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used. User must call CSA_init before calling this function.

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

References HWREG, HWREGB, and privateCSAComputeCLKFrequency().

unsigned long CSA_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 CSA_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used. User must call CSA_init before calling this function.

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

References HWREG, and privateCSAComputeCLKFrequency().

void CSA_VLOoff ( unsigned int  baseAddress)

Turns off VLO

USer must call CSA_init function before invoking this function. Modified registers are CSCTL4

References HWREG.

unsigned int CSA_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 CSA_setDCOFreq ( unsigned int  baseAddress,
unsigned int  dcorsel,
unsigned int  dcofsel 
)

Set DCO frequency

Before invoking the this function, the user must call CSA_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 FR58xx/FR59xx devices: CSA_DCOFSEL_0 - Low frequency option 1 MHZ. High frequency option 1 MHz. CSA_DCOFSEL_1 - Low frequency option 2.67 MHZ. High frequency option 5.33 MHz. CSA_DCOFSEL_2 Low frequency option 3.33 MHZ. High frequency option 6.67 MHz. CSA_DCOFSEL_3 Low frequency option 4 MHZ. High frequency option 8 MHz. CSA_DCOFSEL_4 Low frequency option 5.33 MHZ. High frequency option 16 MHz. CSA_DCOFSEL_5 Low frequency option 6.67 MHZ. High frequency option 20 MHz. CSA_DCOFSEL_6 Low frequency option 8 MHZ. High frequency option 24 MHz.
dcorselselects frequency range option. Valid options are: CSA_DCORSEL_0 [Default - Low Frequency Option] CSA_DCORSEL_1 [High Frequency Option]
Returns:
NONE

References ASSERT, CSA_DCOFSEL_0, CSA_DCOFSEL_1, CSA_DCOFSEL_2, CSA_DCOFSEL_3, CSA_DCOFSEL_4, CSA_DCOFSEL_5, CSA_DCOFSEL_6, CSA_DCORSEL_0, CSA_DCORSEL_1, and HWREG.


Variable Documentation

unsigned long CSA_LFXTClockFrequency = 0
unsigned long CSA_HFXTClockFrequency = 0

Copyright 2012, Texas Instruments Incorporated