尊敬的先生
我使用以下配置向 MSP430F2619S-HT 的 XT2IN 引脚馈送外部8MHZ 时钟信号:
BCSCTL3 = XT2S_3; //选择外部时钟信号:8MHz
BCSCTL1 &=~XT2OFF;//XT2OFF = 0
BCSCTL2 = DIVM_0 + DIVS_0; //MCLK 和 SMCLK 分频器为1
我希望在 SMCLK 和 MCLK 上看到时钟输出、但没有看到任何内容。
该部件如何与外部时钟信号配合使用
王克拉克
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.
尊敬的先生
我使用以下配置向 MSP430F2619S-HT 的 XT2IN 引脚馈送外部8MHZ 时钟信号:
BCSCTL3 = XT2S_3; //选择外部时钟信号:8MHz
BCSCTL1 &=~XT2OFF;//XT2OFF = 0
BCSCTL2 = DIVM_0 + DIVS_0; //MCLK 和 SMCLK 分频器为1
我希望在 SMCLK 和 MCLK 上看到时钟输出、但没有看到任何内容。
该部件如何与外部时钟信号配合使用
王克拉克
你好、Gary Gao
我修改下面的代码
BCSCTL3 = XT2S_3; //选择外部数字时钟
BCSCTL1 &=~XT2OFF; //XT2OFF 为0
BCSCTL2 = DIVM_0 + DIVS_0; //MCLK 分频器为1、SMCLK 分频器为1
操作
{
__DELAY_CYCLES (100);
ClrWdt ();
}while (XT2OF =( BCSCTL3 & XT2OF));
但我仍然看不到 SMCLK 引脚上的输出时钟信号、UART 模块不工作(选择 DCO 模块时工作)、
如何知道时钟从 DCO 切换到外部数字时钟信号是否成功?
王克拉克
您可以尝试使用 XTN 引脚8、该引脚可与我已验证的以下代码配合使用
#include <msp430.h> int main(void) { volatile unsigned int i; WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer if (CALBC1_8MHZ==0xFF) // If calibration constant erased { while(1); // do not load, trap CPU!! } __bic_SR_register(OSCOFF); // enable LFXT1 oscillator BCSCTL1 |= XT2OFF + XTS; // LFXT1CLK is High Frequency BCSCTL3 |= LFXT1S0 + LFXT1S1;// Digital external 0.4- to 16-MHz clock source BCSCTL3 &= ~(XCAP0 + XCAP1); do // wait for oscillator to stablise { IFG1 &= ~OFIFG; // clear flag // do a delay of at least 50uS i = 0xFF; while (i > 0) i--; } while ((IFG1 & OFIFG) != 0);// repeat until flag remains cleared BCSCTL2 |= SELM1 + SELM0; // MCLK Source Select 3: LFXTCLK P5DIR |= 0x78; // P5.6,5,4,3 outputs P5SEL |= 0x70; // P5.6,5,4 options while (1) // 10 MCLK cycle loop { P5OUT |= 0x08; // P5.3 = 1 i = 50000; // Delay do (i--); while (i != 0); P5OUT &= ~0x08; // P5.3 = 0 i = 50000; // Delay do (i--); while (i != 0); } }
我也无法使用 XT2、并尝试在此处找到原因。
你(们)好,Kejun
我已经创建了一个代码来使 XT2与 MCLK 和 SMCLK 一起工作。 您可以尝试它。(使其自由运行、不要使其处于调试模式)
/* --COPYRIGHT--,BSD_EX * Copyright (c) 2012, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************* * * MSP430 CODE EXAMPLE DISCLAIMER * * MSP430 code examples are self-contained low-level programs that typically * demonstrate a single peripheral function or device feature in a highly * concise manner. For this the code may rely on the device's power-on default * register values and settings such as the clock configuration and care must * be taken when combining code from several examples to avoid potential side * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware * for an API functional library-approach to peripheral configuration. * * --/COPYRIGHT--*/ //****************************************************************************** // MSP430x26x Demo - Basic Clock, Output Buffered SMCLK, ACLK and MCLK/10 // // Description: Buffer ACLK on P5.6, SMCLK(DCO) on P5.5, MCLK on P5.4 and // MCLK/10 on P5.3. // ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = CALxxx_8MHZ = 8MHz // //* External watch crystal on XIN XOUT is required for ACLK *// // // MSP430F261x/241x // ----------------- // /|\| XIN|- // | | | 32kHz // --|RST XOUT|- // | | // | P5.6|-->ACLK = 32kHz // | P5.5|-->SMCLK = 8MHz // | P5.4|-->MCLK = DCO // | P5.3|-->MCLK/10 // // B. Nisarga // Texas Instruments Inc. // September 2007 // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A //****************************************************************************** #include <msp430.h> int main(void) { volatile unsigned int i; WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer P5DIR |= BIT4|BIT5|BIT3; // P5.6,5,4,3 outputs P5SEL |= BIT4|BIT5; // P5.6,5,4 options __bic_SR_register(OSCOFF); // enable LFXT1 oscillator BCSCTL1 &= ~XT2OFF; // XT2 ON BCSCTL3 |= XT2S_3;// Digital external 0.4- to 16-MHz clock source BCSCTL3 &= ~XT2OF; // P5OUT |= BIT3; // P5.3 = 1 do // wait for oscillator to stablise { IFG1 &= ~OFIFG; // clear flag // do a delay of at least 50uS i = 0xFF; while (i > 0) i--; } while ((IFG1 & OFIFG) != 0);// repeat until flag remains cleared // P5OUT &= ~BIT3; // P5.3 = 0 do { __delay_cycles( 100 ); }while( XT2OF ==( BCSCTL3 & XT2OF) ); BCSCTL2 |= SELM1|SELS; // MCLK Source Select 3: LFXTCLK // P5OUT |= BIT3; // P5.3 = 1 while (1) // 10 MCLK cycle loop { P5OUT |= BIT3; // P5.3 = 1 i = 50000; // Delay do (i--); while (i != 0); P5OUT &= ~BIT3; // P5.3 = 0 i = 50000; // Delay do (i--); while (i != 0); } }
下面是波形捕获