This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I've been working with the CC430 for years, and I have never managed to be able to get an external 32768Hz oscillator to stabilize. But now it is time to really figure this out, because I want to be able to use the CC430 is products where accurate timing is important, and the REFOCLK just will not do.
I have tried multiple revisions of the chip, multiple crystals, multiple code examples from TI (there has been an evolution over the years), but it never stabilizes. Shown below is the code from the HAL_UCS.c file from the MSP430F5 C library, which also includes some CC430 example. I have tried this code and many variations of it, hoping to find the solution.
void LFXT_Start(uint16_t xtdrive) {
// If the drive setting is not already set to maximum set it to max for LFXT startup
if ((UCSCTL6 & XT1DRIVE_3) != XT1DRIVE_3) {
UCSCTL6_L |= XT1DRIVE1_L + XT1DRIVE0_L; // Highest drive setting for startup
}
while (UCSCTL7 & XT1LFOFFG){ // Check LFXT1 fault flag
UCSCTL7 &= ~(XT1LFOFFG); // Clear LFXT1 fault flag
SFRIFG1 &= ~OFIFG;
}
UCSCTL6 = (UCSCTL6 & ~(XT1DRIVE_3)) | (xtdrive); // set requested Drive mode
}
I am setting Port 5.0 and 5.1 correctly ahead of the initialization. In fact, I have tried just building the example itself. Every time, the code gets stuck in the while loop above, forever. Right now I'm at the point of insanity. Is there any knowledge on this topic? I'm assuming there must be a solution, or else this is an epic hardware bug.
Thanks.
I tried the above LFXT_Start function on a CC430F5137 with a 32768 Hz crystal on XT1 and it successfully started the oscillator. Can you post your complete example?
Here is the example.
void LFXT_Start(u16 xtdrive) {
/// Put LFXT into max drive for startup, then wait for stabilization, then
/// put it into the specified drive mode after stabilization.
UCSCTL6 |= 0xC0;
while (UCSCTL7 & XT1LFOFFG) {
UCSCTL7 &= ~(XT1LFOFFG);
SFRIFG1 &= ~OFIFG;
}
UCSCTL6 = (UCSCTL6 & ~(XT1DRIVE_3)) | (xtdrive); // set Drive mode
}
void main(void) {
WDTCTL = WDTPW + WDTHOLD;
P55SEL |= (0x02 | 0x01);
UCSCTL6 = (0x0100 | 0x00C0 | 0x0004 ); //XCAP=01
LFXT_Start(0);
...
I have tried different settings for XCAP. This board has two 9pF caps on the crystal, although I have also tried the EM430RF board (the basic CC430 kit from TI) with no luck. Every time, the runtime gets stuck in the while loop. The fault bit in UCSCTL7 is locked high. It is high at startup, and high ever-after. Could it be possible that the CC430 is damaging my crystals?
The following line in the example gave a compile error due to an undefined symbol:
P55SEL |= (0x02 | 0x01);
If should be:
P5SEL |= (0x02 | 0x01);
With that fixed, running with a CC430F5137 on an OLIMEX MSP430-CCRFLCD the XT1LFOFFG fault bit was high at startup and cleared by the while loop in LFXT_Start. This board doesn't have any external caps on the 32768 Hz Crystal.
Assuming that the error with using P55SEL instead of P5SEL isn't the cause of your problem, then guess there is a hardware problem.
(The first time I tried to use 32768 Hz Crystal on the OLIMEX MSP430-CCRFLCD the XT1LFOFFG fault bit was always high, but after I "tapped" the Crystal it then started working)
I solved the problem. The code is fine -- the error was a transcription error when bringing it into this forum.
The problem was that, incredibly, of the three CC430 boards I was testing, all of them had some type of HW problem or another that affected the LF crystal. I was able to isolate the shorts. Those boards are now out-of-service. Fortunately, I have about a dozen other CC430 boards lying around. Hopefully, lightning won't strike four times!
**Attention** This is a public forum