Part Number: CC430F6137
Hi,
I installed the 32KHz crystal that came with the em-cc430f6137 boards and ran a simple program that:
Use XT1 as the source of ACLK
Use FLL to adjust the SMCLK frequency to 8MHZ
The code is attached and has been adapted from one of the examples provided by TI:
/* Configure CPU clock for 8MHz */
/* If clock settings are changed, remember to update BSP_TIMER_CLK_MHZ.
* Otherwise, all timer settings would be incorrect.
*/
// Initialize LFXT1
P5OUT &= 0x03;
P5DIR &= ~(BIT0 + BIT1);
P5SEL |= 0x03; // Select XT1
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1 fault flag is cleared
do {
UCSCTL7 &= ~XT1LFOFFG; // Clear XT1 fault flags
} while (UCSCTL7 & XT1LFOFFG); // Test XT1 fault flag
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_5; // Select DCO range 16MHz operation
UCSCTL2 = FLLD_1 + 243; // Set DCO Multiplier for 8MHz
// (N + 1) * FLLRef = Fdco
// (243 + 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
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive
I setup the ports in order to get the clock signals:
PMAPPWD =0x02D52;
P1MAP1 = PM_SMCLK;
P1MAP0 = PM_ACLK;
PMAPPWD = 0;
P1DIR |= BIT0 + BIT1;
P1SEL |= BIT0 + BIT1;
Now I visualized the clocks with a scope, here is the ACLK:
As you can see the frequency reported by the scope is 32.7690KHz.
I see some problems here:
1. The wave is not symmetric, please check the low part which is longer than the high part.
2. This is a static image but in real time the wave is not very steady, it has some fine jumps and the scope is reporting the frequency with highs and lows.
3. I suspect because of the instability of the base frequency, the high frequency (8MHz) is even more jumpy, see the attached video
I would like to have an opinion from an expert, is this the normal behavior or should I look for an error?
Thanks,
Dragos
