Other Parts Discussed in Thread: MSP430F5510
Hi all, I use a MSP430F5510 in my board. I use this code to set the frequency to 24MHz, taken from TI examples:
void Clock_Init(void)
{
// Increase VCore, step by step, to support 24MHz
Clock_SetVCoreUp(0x01);
Clock_SetVCoreUp(0x02);
Clock_SetVCoreUp(0x03);
UCSCTL3 = SELREF_2; // Set DCO FLL reference = REFO
UCSCTL4 |= (SELA_2 | SELS_3 | SELM_3); // Set ACLK = REFO, MCLK = DCOCLK, SMCLK = DCOCLCK
UCSCTL5 |= DIVS_3; // Set SMCLK divider = 8
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_7; // Select DCO range 50MHz operation
UCSCTL2 = FLLD_1 + 731; // Set DCO Multiplier for 24MHz: (731 + 1) * 32768 = 24MHz
__bic_SR_register(SCG0); // Enable the FLL control loop
__delay_cycles(752000); // Worst-case settling time for DCO
// Loop until XT1, XT2 and DCO stabilizes
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
} while (SFRIFG1 & OFIFG); // Test oscillator fault flag
}
// Set the VCore to the specified level
void Clock_SetVCoreUp(unsigned int level)
{
PMMCTL0_H = PMMPW_H; // Open PMM registers for write
SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level; // Set SVS/SVM high side new level
SVSMLCTL = SVSLE + SVMLE + SVSMLRRL0 * level; // Set SVM low side to new level
while ((PMMIFG & SVSMLDLYIFG) == 0); // Wait until SVM is settled
PMMIFG &= ~(SVMLVLRIFG + SVMLIFG); // Clear already set flags
PMMCTL0_L = PMMCOREV0 * level; // Set VCore to new level
if ((PMMIFG & SVMLIFG))
while ((PMMIFG & SVMLVLRIFG) == 0); // Wait till new level reached
SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level; // Set SVS/SVM low side to new level
PMMCTL0_H = 0x00; // Lock PMM registers for write access
}
When I ran the code, I noticed that it was stuck at the last do-while loop, that checks for the oscillator fault flag. I thought that the problem was the too high clock frequency, so I commented the entire code except for the do-while loop. Result? Running the code, it was stuck again at the do-while loop, even if the clock was configured with default settings (2MHz if I remember correctly). So, it seems that the oscillator fault flag is always set, even with the default clock frequency.
However, just to try, I remove the do-while loop and run a simple program that makes a LED blink (in my board I have a LED connected to a I/O port), and everything works even at 24MHz. How is it possible?