hi,
i'm using the MSP430F5438A and i'm trying to set up different frequencies for the three different clocks MCLK SMCLK and ACLK. I'd like to have 8MHz for the MCLK, 1MHz for SMCLK and 32kHz for ACLK. So far it's not working as I'm stuck in the oscillator fault flag loop. Any idea as to what i'm done wrong and how to go about that ? I think it's got to do with the configuration for the UCSCTL4, I might have done it incorrctly but I can't really figure out another way of doing it. Thanks !
VZ
void mcuspeed_mclk_8Mhz_smclk_1Mhz_aclk_32khz (void) {
SetVCore(PMMCOREV_3); // Set VCore = 1.6V for 16MHz clock
P11SEL |= 0x07; // Select P11.0 ACLK, P11.1 MCLK, P11.2 SMCLK
P11DIR |= 0x07; // P11.0 ACLK, P11.0 MCLK, P11.2 SMCLK set for output
UCSCTL3 |= SELREF__REFOCLK; // Set DCO FLL reference = REFO
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_5; // Select DCO range 16MHz operation
UCSCTL2 = FLLD_1 + 249; // Set DCO Multiplier for 8MHz
// (N + 1) * FLLRef = Fdco
// (249 + 1) * 32768 = 8MHz
// Set FLL Div = fDCOCLK/2
__bic_SR_register(SCG0); // Enable the FLL control loop
// Worst-case settling time for the DCO when the DCO range bits have been
// changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
// UG for optimization.
// 32 x 32 x 8 MHz / 32,768 Hz = 250000 = MCLK cycles for DCO to settle
__delay_cycles(250000);
// Loop until XT1,XT2 & DCO fault flag is cleared
do {
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
} while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL4 |= SELM__DCOCLKDIV + SELS__DCOCLK;
}