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.

Oscillator fault flag never clears on 430F5659

We had a problem with the 5659 where the SFRIFG1_bit.OFIFG is never cleared.

After some work and having found no apparent reason the code below was tested in a 430F5659 and a 430F6659.

On the 6659 the flag is cleared while on the 5659 it's not.

Does anyone have any idea why this could be happening?? Any help is appreciated.

#include <io430.h>

static void SetVCoreUp( unsigned char level ) {
SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level;
SVSMLCTL = SVSLE + SVMLE + SVSMLRRL0 * level;
while ( ( PMMIFG & SVSMLDLYIFG ) == 0 ) {
}
PMMIFG &= ~( SVMLVLRIFG + SVMLIFG );
PMMCTL0_L = PMMCOREV0 * level;
if ( ( PMMIFG & SVMLIFG ) ) {
while ( ( PMMIFG & SVMLVLRIFG ) == 0 ) {
}
}
SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
}

static void InitPMM( void ) {
PMMCTL0_H = PMMPW_H;
/* The SetVCoreUp procedure is implemented and used according to "2.2.4 Increasing Vcore to Support Higher MCLK Frequencies" */
if( (PMMCTL0 & (PMMCOREV1 | PMMCOREV0)) < PMMCOREV_1 ) {
SetVCoreUp( 1 );
}
if( (PMMCTL0 & (PMMCOREV1 | PMMCOREV0)) < PMMCOREV_2 ) {
SetVCoreUp( 2 );
}
if( (PMMCTL0 & (PMMCOREV1 | PMMCOREV0)) < PMMCOREV_3 ) {
SetVCoreUp( 3 );
}
SVSMLCTL = !SVMLE /* SVM high-side disabled */
| !SVSLE; /* SVS low-side disabled */
SVSMHCTL = !SVMHE /* SVM high-side disabled */
| !SVSHE; /* SVS high-side disabled */
PMMRIE = 0x00;
PMMCTL0_H = 0x00;
}

int main( void )
{
WDTCTL = (WDTPW | WDTHOLD); /* stop WDT */
InitPMM(); /* SVS, SVM, Vcore */

/* Clocks */
__bis_SR_register(SCG0); // Disable the FLL control loop
/* Clock module */
UCSCTL6 = XT2OFF // Turn off XT2
| XT1DRIVE_3 // Drive XT1 with the highest current for fast startup
| !XTS // XT1 in low frequency mode
| !XT1BYPASS // XT1 Sourced internally
| XCAP_3
| !SMCLKOFF // Turn on SMCLK
| !XT1OFF; // Turn on XT1
UCSCTL0 = 0x0900; // DCO tap = 9, MOD counter = 0
UCSCTL1 = DCORSEL_5 // For 6 to 23 MHz range
| !DISMOD; // Enable modulation
UCSCTL2 = FLLD__2 + 122; // Set DCO Multiplier for 8MHz
// D * (N + 1) * FLLRef = Fdco
// 2 * (122 + 1) * 32768 = 8MHz
UCSCTL3 = SELREF__XT1CLK // FLL reference set to XT1CLK (32768Hz)
| FLLREFDIV__1; // FLL reference divider /1
UCSCTL4 = SELA__XT1CLK // ACLK sourced by XT1CLK
| SELS__DCOCLK // SMCLK sourced by DCOCLK
| SELM__DCOCLK; // MCLK sourced by DCOCLK
UCSCTL5 = DIVPA__1 // ACLK divider to output pin /1
| DIVA__1 // ACLK divider /1
| DIVS__1 // SMCLK divider /1
| DIVM__1; // MCLK divider /1
UCSCTL8 = 0x0700 // Bits 8-10 require to be written in 1
| ACLKREQEN // Enable conditional module request signal for ACLK
| MCLKREQEN // Enable conditional module request signal for MCLK
| !SMCLKREQEN // Disable conditional module request signal for SMCLK
| !MODOSCREQEN; // Disable conditional module request
__bic_SR_register(SCG0); /* Enable the FLL control loop */

do {
UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG); /* Clear XT2, XT1, DCO fault flags */
SFRIFG1_bit.OFIFG = 0; /* Clear fault flags */
} while ( SFRIFG1_bit.OFIFG ); /* Test oscillator fault flag */

UCSCTL6 &= ~(XT1DRIVE0 | XT1DRIVE1); /* XT1 is now stable, reduce drive strength */
__bis_SR_register(SCG0); /* Disable the FLL control loop */

// Unreach code
for(;;);
}

  • Hi,

    You check the LOCKBAK bit BACKCTL register.

  • I'm checking that right now. 

    Thank you

  • Thank you, it was the right path.

    TI should be more explicit about this in the userguides. It's really hard to find, and even then not very clear.



    The issue seems to be associated with BAKDIS
    After a POR the oscillator is powered from Vbat and XT1 operation is not modifiable.
    BAKDIS changes the power to VCC and allows changing the module's operation.

    After testing BAKCTL |= BAKDIS seems to be enough to fix the issue, but forums and application notes suggest clearing LOCKBAK as well.



    From the user guide:

    The secondary supply VBAT powers the backup-supplied subsystem

    • at power on
    • if bit BAKDIS=0 in the BAKCTL register and
    – if the primary supply drops below the configured high-side SVS level
    – if the high-side SVS (SVSH) is disabled
    – during LPMx.5
    – if bit BAKSW=1 in the BAKCTL register

    The primary supply DVCC powers the backup-supplied subsystem

    • if the primary supply rises above the power-on level of the high-side SVS level
    • if the primary supply remains above the configured high-side SVS level
    • if bit BAKDIS=1 in the BAKCTL register

    If the backup-supplied subsystem is powered by the secondary supply VBAT the access and control to
    modules located in the subsystem is restricted:

    • The data stored in the backup RAM is retained but cannot be accessed.
    • The RTC - if enable - together with the 32-kHz crystal oscillator continue to operate but the time and
    date information cannot be accessed.
    • Changes to the LF-cyrstal oscillator setting in the clock system don't take effect.

    If the backup-supplied subsystem is powered by the primary supply DVCC and LOCKBAK=0 the modules
    located in the subsystem can be access and controlled normally.




    From slau316

    The XT1 oscillator on the F6638 device is powered by the backup or secondary battery source.
    On exit from a BOR it is required to clear the LOCKIO bits in the BACKCTL register to unlock
    XT1 pins for operation. This requirement is unique to the F66xx family and can be done by the
    following code.
    while(BAKCTL & LOCKIO) // Unlock XT1 pins for operation
    BAKCTL &= ~(LOCKIO);
  • The power backup systems are indeed a bit confusing. The problem is that multiple things are connected here.
    LOCKBAK is apparently set when the main supply fails and the system switches to backup supply. It is normally meant for intentional LPMx.5 operation, where the system recovers with a BOR (but not a power-up) and module config shall not be affected by the boot code system initialization. However, it does seem to happen even if the backup system just temporarily switches to the backup supply, and device operation continues normally.
    Such a temporary switch may even happen during changes of the core voltage level.
    BAKDIS=1 'fixes' the problem by disabling the switch to the backup supply.
    BTW: it is recommended (or even mandatory) to only change one PMMCOREV level at a time and wait for the SVS to catch up.

**Attention** This is a public forum