//*****************************************************************************
//
//Target frequency for MCLK in kHz
//
//*****************************************************************************
#define UCS_MCLK_DESIRED_FREQUENCY_IN_KHZ 12000
//*****************************************************************************
//
//MCLK/FLLRef Ratio
//
//*****************************************************************************
#define UCS_MCLK_FLLREF_RATIO 366
//*****************************************************************************
//
//Variable to store current Clock values
//
//*****************************************************************************
unsigned long clockValue = 0;
//*****************************************************************************
//
//Variable to store status of Oscillator fault flags
//
//*****************************************************************************
unsigned int status;
void main(void)
{
//Stop WDT
WDT_A_hold(WDT_A_BASE);
//Set VCore = 1 for 12MHz clock
PMM_setVCore(PMM_BASE,
PMM_CORE_LEVEL_1
);
//Set P8.0 ,P8.1to output direction
GPIO_setAsOutputPin(
GPIO_PORT_P8,
GPIO_PIN0+GPIO_PIN1
);
//Set Ratio and Desired MCLK Frequency 12MHz and initialize DCO
UCS_initFLLSettle(
UCS_BASE,
UCS_MCLK_DESIRED_FREQUENCY_IN_KHZ,
UCS_MCLK_FLLREF_RATIO
);
// Enable global oscillator fault flag
SFR_enableInterrupt(SFR_BASE,
SFR_OSCILLATOR_FAULT_INTERRUPT
);
// Enable global interrupt
__bis_SR_register(GIE);
//Start timer in up down mode
//Enter LPM3
__bis_SR_register(LPM3_bits);
//For debugger
__no_operation();
//Verify if the Clock settings are as expected
clockValue = UCS_getSMCLK(UCS_BASE);
clockValue = UCS_getMCLK(UCS_BASE);
clockValue = UCS_getACLK(UCS_BASE);