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.

Led blinking fast when oscillator fault interrupt flag not cleared

Hi,

I am a beginner in MSP430. I was going through the workshop videos of traning, In Lab3 there is an example where we run cpu with VLO(12Khz) by disabling System clock generator 0 and System clock generator 1 while i was writing that i forgot clear OFIFG in IFG1 register then also program compiled but the led started blinking faster than expected . I haven't written any interrupt routine to handle oscillator fault.

#include <msp430g2553.h>

/* Added because of inconsistency  between
 * the header files of msp430g2231.h and
 * msp430g2553.h(i.e in msp430g2553.h assembly
 * header file names
 * of Timers are not renamed in c header file
 */

#ifndef TIMER0_A1_VECTOR
#define TIMER0_A1_VECTOR TIMERA1_VECTOR
#define TIMER0_A0_VECTOR TIMERA0_VECTOR
#endif


/*
 * main.c
 */
void main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

	P1DIR = BIT6+BIT0 ;				//Configure P1.6 as output by writing 1 to corresponding pin
	P1OUT &= ~(BIT0+BIT6);					//make output of that pin as zero
	
	BCSCTL3 |= LFXT1S_2;		//Configure basic clock system+ to use VLO
        //I forgot add the following line in my program
	IFG1 &= ~OFIFG;			//Disabling Oscillator interrupt pending flag
	_bis_SR_register(SCG0+SCG1);
	BCSCTL2 |= SELM_3 + DIVM_3;

	while(1)
	{
		P1OUT |= BIT6; // LED on
		_delay_cycles(100);
		P1OUT &= ~BIT6 ; // LED off
		_delay_cycles(5000);
	}

}

Can some tell me the reason for fast blinking.

  • In case of an oscillator fault, MCLK falls back to DCO and you can't switch the DCO off as long as the CPU is active and needs MCLK.

    Switching MCLK from DCO to VLO is only possible when OFIFG is clear. So by not clearing OFIFG, you prevented the system to switch MCLK to VLO (because originally, XT1 was set to external crystal and therefore had its fault flag set) and despite of setting SCG0 and SCG1, the CPU continued to run from DCO with ~1MHz.

    See the 'fail safe operation' chapter in the clock system section of the users guide.

**Attention** This is a public forum