特别是判断外置16M晶振起振的判断语句,官网的例程只有低频的32768的配置以及判断。求一下外部高频的配置和判断起振标志语句
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.
特别是判断外置16M晶振起振的判断语句,官网的例程只有低频的32768的配置以及判断。求一下外部高频的配置和判断起振标志语句
也有用外部高频晶振的
//****************************************************************************** // 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_0 int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT // Configure P8.7 as USSXT_BOUT P8DIR |= BIT7; P8SEL1 |= BIT7; P8SEL0 &= ~BIT7; // Configure P1.0 as output for LED P1OUT &= ~BIT0; P1DIR |= BIT0; // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Clock System Setup CSCTL0_H = CSKEY_H; // Unlock CS registers CSCTL1 = DCOFSEL_3; // Set DCO to 8MHz // Set SMCLK = MCLK = DCO, ACLK = VLOCLK CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; CSCTL3 = DIVA__1 | DIVS__8 | DIVM__8; // MCLK = SMCLK = 1MHz CSCTL0_H = 0; // Lock CS registers //Configure USSXT Oscillator HSPLLUSSXTLCTL = 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 Interrupt TA4CTL = 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 stable while((HSPLLUSSXTLCTL & OSCSTATE) == 0); // Output oscillator on pin HSPLLUSSXTLCTL &= ~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 LPM TA4CTL = MC__STOP; __bic_SR_register_on_exit(LPM3_bits | GIE); __no_operation(); }