Hello
Im hoping someone can help me.
I am trying to set up my MSP430F5659 with an external crystal osc on XT2 that is 4 MHz. (note, it's a crystal, NOT an external clock - so no bypass, right?)
I'd like to setup ACLK = 4 MHZ, SMCLK = 16 MHz , MCLK = 16 MHz
What I'm getting is a whole lot of nothing. I have a fault OFIFG = 1 after the below routine runs.
can anyone see my flaw?
WDTCTL = WDTPW + WDTHOLD;
SFRIFG1 &= ~OFIFG; // clear osc flag
UCA0CTL1 = UCSWRST; // reset USCI 1
UCA0CTL0 = 0x00;
UCSCTL5 = 0x00; // ACLK, SMCLK source divider
// 0 = dont divide ACK and SMCLK
istate_t istate = __get_interrupt_state();
__disable_interrupt(); // Disable global interrupts
/
P7SEL |= 0x03; // Port select XT1
UCSCTL6 |= (XT1OFF); // XT1 off
P7SEL |= 0x03; // Port select XT1
UCSCTL6 &= ~(XT2OFF); // XT2 on
UCSCTL3 = SELREF__XT2CLK |FLLREFDIV_4 ; // source for ffl is Xt2, div 4
// output is DCO
// 4 MHz div 4 = 16 MHz DCO
UCSCTL4 = SELA__XT2CLK | SELS__DCOCLK | SELM__DCOCLK ; // ack clock source is xt2 , source for mclk is DCO , source for smclk is DCO
while(BAKCTL & LOCKIO)
BAKCTL &= ~(LOCKIO);
do
{ // clear all osc, DCO flags
UCSCTL7 &= ~ ( DCOFFG| XT1LFOFFG | XT1HFOFFG | XT2OFFG );
SFRIFG1 &= ~OFIFG;
} while(SFRIFG1 & OFIFG); /// ***** I FAIL RIGHT HERE!!!! I ALWAYS HAVE OFIFG = 1 ******************
UCSCTL1 |= DCORSEL_5; // MCLK = 16MHz(see data sheet p63-- not sure I need this???)
UCSCTL2 &= 0x0000;
Please - any help is much appreciated.
thanx
Dubs