I have an MSP430F5336 device and want to source SMCLK from XT2. According to the documentation, this should be possible. However, when I configure it for this mode, it gets sourced from DCOCLKDIV instead. Am I missing something obvious here?
In my design, XT2 is being driven by a clock and not a crystal. Therefore, XT2 is in bypass mode. Also, all oscillator fault flags are cleared, so there is nothing that should be reverting the failsave source back to the DCOCLKDIV.
This is the code I am using:
P7DIR = 0x0; // XT2IN is input
P7SEL = 0x04; // P7.2 = special for XT2IN
// since XT2 is bypassed, XT2 is turned off
UCSCTL6 &= ~(XT2OFF + XT2DRIVE_3 + XT1DRIVE_3 + XCAP_3);
UCSCTL6 |= XT2BYPASS + XT1OFF;
UCSCTL4 = (SELA__DCOCLK | // ACLK = DCOCLK
SELM__DCOCLK | // MCLK = DCOCLK
SELS__XT2CLK); // SMCLK = XT2
Some parts have been left out but this is the relevant parts.
Just to be thorough, I seem to remember reading that XT2 has to be enabled in order for XT2 to source other clocks. I tried the following with the same results:
P7DIR = 0x0; // XT2IN is input
P7SEL = 0x04; // P7.2 = special for XT2IN
// since XT2 is bypassed, XT2 is turned off
UCSCTL6 &= ~(XT1DRIVE_3 + XCAP_3);
UCSCTL6 |= XT1OFF;
// Switch clock sources away from XT1 in order for it to be switched off
// and allow for XT2 to lock.
UCSCTL4 = (SELA__DCOCLKDIV | // ACLK = DCODIV clk
SELM__DCOCLKDIV | // MCLK = DCODIV clk
SELS__DCOCLKDIV); // SMCLK = DCODIV clk
// Loop until XT1,XT2 & DCO stabilizes
do
{
// Clear XT2,XT1,DCO fault flags
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear fault flags
SFRIFG1 &= ~OFIFG;
}
while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL4 = (SELA__DCOCLK | // ACLK = DCOCLK
SELM__DCOCLK | // MCLK = DCOCLK
SELS__XT2CLK); // SMCLK = XT2
In both of these cases, the XT2 clock does not make it to the SMCLK. I have it ported to one of the IO pins and can observe it. It appears to be DCOCLKDIV but may also be just the DCOCLK. I can't seem to make it work for the SMCLK, although it does work for the reference clock of the FLL and works great there, so I know that somewhere in the system is getting and using the correct XT2 clock.
Any insights would be great.
Thanks,
Brent