请问在MSP430F的MCU在采用片内振荡器或外部有源晶振时,能否在XOUT脚上测到波形?
另外在将XOUT管脚用作IO口时(P2SEL &= ~BIT7),为什会引起外部时钟失效?(OFIFG 始终为1,清不了0)
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.
内部振荡和外部有源晶振在XOUT是测不到波形。XOUT失效的问题是时钟配置问题,在msp430 user guider有一句对有源晶振的说明:In bypass mode of operation, XIN can accept an external clock
input signal and XOUT is configured as a general-purpose I/O. The PSEL bit associated with XOUT is a
don't care.
我试了,不论把POWER_PIN 和POWER_ON 加到do while循环前面或是后面,如果没有P2SEL &= ~BIT7 这句, P2,7(XOUT)脚都没有输出. 如果加上,则无论在什么地址, OFIFG则始终置1,软件无法清除的.
程序如下:
#define POWER_PIN P2SEL &= ~BIT7;P2DIR |= BIT7;
#define POWER_ON P2OUT |= BIT7;
#define POWER_OFF P2OUT &= ~BIT7;
#define ENABLE_SET P1DIR |= BIT0 // P1.0 ist switched in output direction
#define TRF_ENABLE P1OUT |= BIT0 // EN pin on the TRF796x
#define TRF_DISABLE P1OUT &= ~BIT0
viod main(viod)
{
unsigned char ii1 = 0;
WDTCTL = WDTPW + WDTHOLD;
POWER_PIN; //如果加上这句,则程序一直在DO循环里出不来,取消这句则一切正常。
POWER_ON;
ENABLE_SET;
TRF_ENABLE;
BCSCTL1 |= XTS + XT2OFF; // ACLK = LFXT1 HF XTAL
BCSCTL3 |= LFXT1S1; // turn external oscillator on
while ((IFG1 & OFIFG) == OFIFG)
IFG1 &= ~OFIFG;
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (ii1 = 0xFF; ii1 > 0; ii1--) // Time delay for flag to set
{
}
} while ((IFG1 & OFIFG) == OFIFG); // OSCFault flag still set? 如果XOUT用作IO口时,程序一直在里面,OFIFG位一直为1
BCSCTL2 |= SELM1 + SELM0 + SELS; // MCLK = SMCLK = HF LFXT1 (safe)
while(1);
}
您好,
在User's Guide 277页中有这么一句“LFXT1 may be used with an external clock signal on the XIN pin in either LF or HF mode when LFXT1Sx = 11, OSCOFF = 0 and XCAPx = 00,”
也就是说如果使用外部时钟信号,寄存器的相应位做如下设置:XTS = 0,LFXT1Sx = 11, OSCOFF = 0 ,XCAPx = 00
POWER_PIN也应当设置。