Hi,
I copied a file from code composer which is titled: msp430fr59xx_cs_05.c which takes in an external 32.768KHz clock on the LFXT input.
The only thing I modified is that I changed from LFXT to HFXT as seen in my code below. I still can't see the right clock on the output ( I routed SMCLK). The input clock that I inject into the HFXT input does not seem to affect the output at all. Can you please tell me what I might be doing wrong?
Thanks!
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
P1DIR |= BIT2 | BIT3; // P1.2 and P1.3 output
P1SEL0 |= BIT2 | BIT3; // P1.2 and P1.3 options select
PJSEL0 |= BIT6; // For HFCLK
PJSEL1 &= ~BIT6; // For HFCLK
P3DIR |= BIT4;
P3SEL0 |= BIT4; // Output SMCLK
P3SEL1 |= BIT4;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL1 = DCOFSEL_6; // Set DCO to 8MHz
CSCTL2 = SELA__VLOCLK | SELS__HFXTCLK | SELM__DCOCLK;// Set ACLK = VLO; SMCLK = HFXTCLK IN
CSCTL3 = DIVA__8 | DIVS__1 | DIVM__8; // Set all dividers
CSCTL0_H = 0;
CSCTL4 = HFXTBYPASS | HFXTOFF;
do
{
CSCTL5 &= ~HFXTOFFG; // Clear XT1 and XT2 fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
// Now that osc is running enable fault interrupt
SFRIE1 |= OFIE;
__bis_SR_register(LPM0_bits); // Wait in LPM0 for fault flag
__no_operation();
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=UNMI_VECTOR
__interrupt void UNMI_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(UNMI_VECTOR))) UNMI_ISR (void)
#else
#error Compiler not supported!
#endif
{
do
{
// set a breakpoint on the line below to observe XT1 operating from LFMODOSC
// when the breakpoint is hit during a crystal fault
CSCTL5 &= ~HFXTOFFG; // Clear XT1 fault flag
SFRIFG1 &= ~OFIFG;
P1OUT |= BIT0;
__delay_cycles(25000); // time for flag to get set again
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
P1OUT &= ~BIT0;
}