特别是判断外置16M晶振起振的判断语句,官网的例程只有低频的32768的配置以及判断。求一下外部高频的配置和判断起振标志语句
灰小子:
例程里有使用8Mhz外部晶振的例子
www.ti.com/…/slac747
user5841715:
回复 灰小子:
我下了例程,可是他那里边用的8M是用DCO生成的,不是外部高频振荡器吧
灰小子:
回复 user5841715:
也有用外部高频晶振的
//****************************************************************************** //MSP430FR60xx Demo - Output USSXT OSC at 8MHz on a pin. // //Description: Configure USSXT = 8MHz and output on a pin. This can be used //for monitoring the clock or use the clock as the source of another subsystem. // //MSP430FR6047 //--------------- ///|\|| //| || //--|RST| //|P1.0|---> LED //||-USSXTIN //||-USSXTOUT //|P8.7|---> USSXT_BOUT (8MHz) // //Katie Pier //Texas Instruments Inc. //June 2017 //Built with IAR Embedded Workbench V6.50 & Code Composer Studio V7.1 //****************************************************************************** #include <msp430.h>#define OSCTYPE__CRYSTAL OSCTYPE_0int main(void) {WDTCTL = WDTPW | WDTHOLD;// Stop WDT// Configure P8.7 as USSXT_BOUTP8DIR |= BIT7;P8SEL1 |= BIT7;P8SEL0 &= ~BIT7;// Configure P1.0 as output for LEDP1OUT &= ~BIT0;P1DIR |= BIT0;// Disable the GPIO power-on default high-impedance mode to activate// previously configured port settingsPM5CTL0 &= ~LOCKLPM5;// Clock System SetupCSCTL0_H = CSKEY_H;// Unlock CS registersCSCTL1 = DCOFSEL_3;// Set DCO to 8MHz// Set SMCLK = MCLK = DCO, ACLK = VLOCLKCSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;CSCTL3 = DIVA__1 | DIVS__8 | DIVM__8;// MCLK = SMCLK = 1MHzCSCTL0_H = 0;// Lock CS registers//Configure USSXT OscillatorHSPLLUSSXTLCTL = OSCTYPE__CRYSTAL |USSXTEN;// Set up timer to wait in LPM for crystal stabilization time = 4096 clocks for crystal resonator.// For 8MHz XTAL, 4096 clocks = 512us. Using VLO = 9.4kHz, wait 5 timer clock cycles = 532us.TA4CCR0 = 5;TA4CCTL0 = CCIE;// Enable InterruptTA4CTL = TASSEL__ACLK | TACLR | MC__UP; // Timer sourced from ACLK (VLO), clear timer__bis_SR_register(LPM3_bits | GIE);// Enter LPM3 w/interrupt__no_operation();// For debug// Check if oscillator is stablewhile((HSPLLUSSXTLCTL & OSCSTATE) == 0);// Output oscillator on pinHSPLLUSSXTLCTL &= ~XTOUTOFF;while(1){P1OUT ^= BIT0;// Toggle LED to show oscillator init complete__delay_cycles(50000);// Wait 100,000 CPU cycles} }// Timer A4 interrupt service routine #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector = TIMER4_A0_VECTOR __interrupt void Timer4_A0_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(TIMER4_A0_VECTOR))) Timer4_A0_ISR (void) #else #error Compiler not supported! #endif {// Stop the timer and wake from LPMTA4CTL = MC__STOP;__bic_SR_register_on_exit(LPM3_bits | GIE);__no_operation(); }