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'm trying to configure an MSP430FR5969 to use an external 16MHz clock oscillator which drives the HFXIN pin. However, I am not able to successfully configure the clock system to use this clock. The clock source seems to default to internal MODCLK (MODOSC), because my timer code sppears to be driven by a 4.8MHz source instead of a 16MHz source. This failsafe default occurs when a HFXT clock fault occurs that cannot be cleared, as described in the data sheet. I've probed the PCB and the clock looks stable with no overshoot, 50% duty cycle, etc. I am looking for suggestions as to what might be wrong.
Here is my code to configure MSP430FR5969 for use of the 16MHz ext. clock:
/* * Init for MSP430FR5969 with 16MHz external oscillator driving the HFXIN pin */ void hfxtClockInit_5MHzClock(void){ /* set external pins for use as HFXT */ PJOUT = 0x00; // DS table 6-61, xtal operation is PJSEL1.n=0 PJSEL0.n=1, n=6,7 PJSEL1 = 0x00; PJSEL0 |= BIT6 | BIT7; __delay_cycles(16000UL); CSCTL0_H = CSKEY >> 8; // Unlock CS registers CSCTL1_L = 0b00000000; // DCO 1Mhz (but DCO not used) CSCTL2 = SELS__HFXTCLK | SELM__HFXTCLK; // Set SMCLK and MCLK source = HFXT CSCTL3 = DIVS__1 | DIVM__1; // Set all dividers to 1 // 16MHz is borderline case for HFFREQ_n bits?, see table 3-1 in SLAU367 CSCTL4 |= HFFREQ_3 | HFXTBYPASS; // set clock input freq range // check and clear fault regs do { CSCTL5 &= ~(LFXTOFFG | HFXTOFFG); // Clear XT1 and XT2 fault flag SFRIFG1 &= ~OFIFG; }while (SFRIFG1&OFIFG); // Test oscillator fault flag CSCTL0_H = 0; // Lock CS registers }
Hello Wade!
In the TI Resource Explorer you will find an example code named "msp430fr59xx_cs_04.c" which shows an example of using a crystal on the XT2 HF pins. Please refer to this example code along with section 3.3 of the User's Guide in order to see which commands and registers need to be modified to meet your specific requirements.
Best regards,
Matt Calvo
I looked at that example... my design uses a MSP430fr5994 with only a 16MHz external clock oscillator.. no 32KHz low freq clock. That example uses a LFXCLK, and sets the DCO to 8MHz. This is not what I'm looking for.
I want to set all clocks to 16MHz (SMCLK, MCLK), I do not want to use the DCO.
When I run this code, the clocks are running at 4.8MHz-ish.
Is there a way to disable the DCO and just tie everything to the external clock oscillator? I
Here is the clock setup code (that does not work right):
// Problems setting the external 16MHz clock, this is not working
// Clock System Setup
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL1_L = 0; // ??? DCO not used
CSCTL2 = SELS__HFXTCLK | SELM__HFXTCLK; // Set SMCLK and MCLK source = HFXT
CSCTL3 = DIVS__1 | DIVM__1; // Set all dividers to 1
CSCTL4 |= HFFREQ_2 | HFXTBYPASS; // set clock input freq range
CSCTL5 &= ~(LFXTOFFG | HFXTOFFG); // Clear XT1 and XT2 fault flag
SFRIFG1 &= ~OFIFG;
CSCTL0_H = 0; // Lock CS registers
I am just using the DCO to do development for now, but this is not what I want:
// DCO code, don't want to use this... external clock init not working
// Clock System Setup
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL1 = DCORSEL | DCOFSEL_4; // Set DCO to 16MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set SMCLK = MCLK = DCO, ACLK = VLOCLK
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL0_H = 0; // Lock CS registers
W
**Attention** This is a public forum