哪位朋友用过其中的XT2,5xx系列的寄存器跟以前的差别比较大。我现在一直不能设置好XT2作为 MCLK。其中的时钟方面的寄存器设置如下:
P5SEL=0x0C; //crystal high ON P5.2.P5.3
P7SEL=0x03; //crystal low ON P7.0,P7.1
UCSCTL4= SELA_0 + SELS_5 + SELM_5;
UCSCTL5= DIVPA_0+ DIVA_0 + DIVS_4 + DIVM_0;
UCSCTL6= XT2DRIVE_0 + XT2BYPASS + XT1DRIVE_0 + XT1BYPASS + SMCLKOFF ;
UCSCTL7 &= ~(XT2OFF+SMCLKOFF); // Activate XT2 high freq xtal
哪位高手帮指点一下。谢谢
//******************************************************************************
// MSP430F54x Demo - XT2 sources MCLK & SMCLK
//
// Description: This program demonstrates using XT2 to source MCLK. XT1 is not
// connected in this case.
//
// By default, LFXT1 is requested by the following modules:
// - FLL
// - ACLK
// If LFXT1 is NOT used and if the user does not change the source modules,
// it causes the XT1xxOFIFG flag to be set because it is constantly looking
// for LFXT1. OFIFG, global oscillator fault flag, will always be set if LFXT1
// is set. Hence, it is important to ensure LFXT1 is no longer being sourced
// if LFXT1 is NOT used.
// MCLK = XT2
//
// MSP430F5438
// -----------------
// /|\ | |
// | | |
// ---|RST |
// | XT2IN|-
// | | HF XTAL (455kHz - 16MHz)
// | XT2OUT|-
// | |
// | P11.1|--> MCLK = XT2
// | P11.2|--> SMCLK = XT2
//
// M Smertneck / W. Goh
// Texas Instruments Inc.
// September 2008
// Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "msp430x54x.h"
void main(void)
{
unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P11DIR = BIT1+BIT2; // P11.1-2 to output direction
P11SEL |= BIT1+BIT2; // P11.1-2 to output SMCLK,MCLK
P5SEL |= 0x0C; // Port select XT2
UCSCTL6 &= ~XT2OFF; // Ena××e XT2 even if not used
UCSCTL3 |= SELREF_2; // FLLref = REFO
// Since LFXT1 is not used,
// sourcing FLL with LFXT1 can cause
// XT1OFFG flag to set
UCSCTL4 |= SELA_2; // ACLK=REFO,SMCLK=DCO,MCLK=DCO
// Loop until XT2 & DCO stabilize
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
for(i=0;i<0xFFFF;i++); // Delay for Osc to stabilize
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
__no_operation();
UCSCTL4 |= SELS_5 + SELM_5; // SMCLK=MCLK=XT2
while(1); // Loop in place
}
我就是在TI上找的,,,只不过隐藏的比较深罢了。。
如果在XT1接高频晶振的话需要怎么设置啊,我在XT1接了7.3728的晶振,结果不起振
请问一下:UCSCTL4 |= SELA_2; // ACLK=REFO,SMCLK=DCO,MCLK=DCO这句看得不是很理解,为什么这么写就知道了SMCLK选择的时钟源是DCO,MCLK选择的时钟源是DCO呢?
其他位是选择默认的,一般都是0,自动选择的。看下时钟这章找到这个寄存器说明就很清楚了
可是SMCLK选择DCOCLKDIV为时钟源MCLK选择DCOCLKDIV为时钟源