Hello,
I use a MSP430FR6922 controller on my board. I want to set ACLK as LFXTCLK=32.768kHz, MCLK=DCOCLK=16MHz,SMCLK=DCOCLK in my code. then SMCLK/4=4MHz...
My code is:-
#include "common.h"
/* Function to initialize device at internal crystal 16MHz and external 32.768khz*/
void dev_init_16M(void)
{
PJSEL0 |= BIT4 | BIT5; // For XT1
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
// Configure one FRAM wait state as required by the device data sheet for MCLK
// operation beyond 8MHz _before_ configuring the clock system.
FRCTL0 = FRCTLPW | NWAITS_1;
// Clock System Setup
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL1 = DCOFSEL_4 | DCORSEL; // Set DCO to 16MHz
CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK; // Set SMCLK = MCLK = DCO=16Mhz,ACLK=LFXT=32.768kHZ
CSCTL3 = DIVA__1 | DIVS__4 | DIVM__1; // Set all dividers SMCLK/4=4MHz
CSCTL4 &= ~LFXTOFF;
do
{
CSCTL5 &= ~LFXTOFFG; // Clear XT1 fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
// Now that osc is running enable fault interrupt
// SFRIE1 |= OFIE;
// __bis_SR_register(LPM0_bits); // Wait in LPM0 for fault flag
CSCTL0_H = 0; // Lock CS registers}
}
//
//#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
//#pragma vector=UNMI_VECTOR
//__interrupt void UNMI_ISR(void)
//#elif defined(__GNUC__)
//void __attribute__ ((interrupt(UNMI_VECTOR))) UNMI_ISR (void)
//#else
//#error Compiler not supported!
//#endif
//{
// do
// {
// // set a breakpoint on the line below to observe XT1 operating from VLO
// // when the breakpoint is hit during a crystal fault
// CSCTL5 &= ~LFXTOFFG; // Clear XT1 fault flag
// SFRIFG1 &= ~OFIFG;
// P1OUT |= BIT0;
// __delay_cycles(25000); // time for flag to get set again
// }while (SFRIFG1&OFIFG); // Test oscillator fault flag
//}
When I ran the code, I noticed that it was stuck at the last do-while loop, that checks for the oscillator fault flag.
What is the reason?? My code is wrong?? or it is because of hardware issue??
please help..its urgent