MSP430 clock frequency configuration process
[Copy link]
1 XT1 clock configuration initialization
/****************************************************************************
* Function name: XT1_Config(STATUS status)
* Function description: Set whether to enable XT1
* Parameter description: STATUS status: whether to enable XT1
* Function return: None
* Example: XT1_Config(ENABLE); //Enable XT1
************************************************************************************/
static inline void XT1_Config(STATUS status)
{
if(status != DISABLE)
{
if(UCS->XT1_OFF == BIT_SET)
{
GPIO_MultiBits_Init(P5,(GPIO_Pin_4|GPIO_Pin_5),GPI|SEL); //Select XT1 Second function
UCS->XT1_OFF = RESET ; // Enable XT1
do
{
UCS->XT1_LFOFFG = RESET; // Clear XT1,CLOCK_DCO Failure flag
SFRIFG1 &= ~OFIFG; //
}while (UCS->XT1_LFOFFG == BIT_SET); //
}
}
else
{
UCS->XT1_OFF = BIT_SET ; // Turn off XT1
}
}
2 XT2 clock configuration initialization
/****************************************************************************
* Function name: XT2_Config(STATUS status)
* Function description: Set whether to enable XT2
* Parameter description: STATUS status: whether to enable XT2
* Function return: None
* Example: XT2_Config(TRUE); //Enable XT2
************************************************************************************/
static inline void XT2_Config(STATUS status)
{
if(status != DISABLE)
{
if(UCS->XT2_OFF == BIT_SET)
{
GPIO_MultiBits_Init(P5,(GPIO_Pin_2|GPIO_Pin_3),GPI|SEL); //Select CLOCK_XT2 Second function
UCS->XT2_OFF = RESET; //Enable CLOCK_XT2
do
{
UCS->XT2_OFFG = RESET;
SFRIFG1 &= ~OFIFG;
}while (UCS->XT2_OFFG == BIT_SET);
}
}
else
{
UCS->XT2_OFF = BIT_SET; // Turn off XT2
}
}
3 The internal clocks
CLOCK_VLO and CLOCK_REFO are internal clock sources and do not require configuration or initialization.
|