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.
在XIN XOUT上接了4M的晶振.按下面配置
PJSEL0 |= BIT4+BIT5; // Enable xin xout
CSCTL0_H = 0xA5;
CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting 8MHZ
CSCTL2 = SELA_0 + SELS_3 + SELM_3; // set ACLK = XT1; MCLK = DCO
CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // set all dividers
CSCTL4 |= XT1DRIVE_0;
CSCTL4 &= ~XT1OFF;
do
{
CSCTL5 &= ~XT1OFFG;
// Clear XT1 fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
这是例程里面的..
但是不起振,一直出现XT1OFG...
但是置位了XT1BYPASS位以后却通过了,但BYPASS位不是旁路么,旁路了晶振就直接变成了时钟源???按理说不应该置位啊;;;
之前做过一个4MHZ外置晶振的例子,
请看下面代码:
#include "msp430fr5739.h"
unsigned int tt = 0;
unsigned char RXData = 0;
unsigned char TXData = 0;
unsigned char check = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // stop watchdog
// XT1 Setup
PJSEL0 |= BIT4 + BIT5;
CSCTL0_H = 0xA5;
CSCTL1 |= DCOFSEL1 | DCOFSEL0; // Set max. DCO setting
CSCTL2 = SELA_0 + SELS_0 + SELM_0; // set ACLK = XT1; MCLK = DCO
CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // set all dividers
CSCTL4 |= XT1DRIVE_0 | XTS;
CSCTL4 &= ~XT1OFF;
do
{
CSCTL5 &= ~XT1OFFG;
// Clear XT1 fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
// Configure UART 0
UCA0CTL1 |= UCSWRST;
// Configure UART pins
P2SEL1 |= BIT0 + BIT1;
P2SEL0 &= ~(BIT0 + BIT1);
UCA0CTL1 = UCSSEL_1;
UCA0BR0 = 6;
UCA0BR1 = 0;
UCA0MCTLW |= (0x00 << 8) | 0x02 | UCOS16;
UCA0CTL1 &= ~UCSWRST;
while(1)
{
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x50;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x55;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x38;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x50;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x51;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x52;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x53;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x54;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = 0x55;
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = '\r';
for(tt=0;tt<1000;tt++);
while (!(UCA0IFG&UCTXIFG));
while(UCA0STATW & UCBUSY);
UCA0TXBUF = '\n';
for(tt=0;tt<1000;tt++);
}
}