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.

UCS_initFLL (and UCS_initFllSettle) set wrong frequency? (MSP430F5508)

Other Parts Discussed in Thread: MSP430F5508

I'm having an issue where the DriverLib for MSP430F5xx-6xx is setting the clock frequency incorrectly. It is giving me an output that is 2x what I specified.

Here is the code I'm using (in __low_level_init). Note that the calculation for  PFM_FLL_DCO_RATIO results in a value of 488 (0x1E8) and I see 0x1E7 in the FLLN register bits, but the driver appears to also set FLLD to 0x1 resulting in an incorrect frequency.

Documentation says that ratio should be fsystem / fref

This is for MSP430F5508 device. DriverLib version 1.30.00.15

------------------- CODE ----------------------

#include "inc\hw_memmap.h"
#include "wdt_a.h"
#include "gpio.h"
#include "ucs.h"

/* External crystal frequencies */
#define PFM_XT1_FREQ 32768
#define PFM_XT2_FREQ 0

/* Definitions for the DCO configuration */
#define PFM_DCOCLK_FREQ_KHZ 16000
#define PFM_FLL_DCO_RATIO (((unsigned long)PFM_DCOCLK_FREQ_KHZ * 1000)/PFM_XT1_FREQ)

static void SetupClocks( void );
static void SetupIO( void );

int __low_level_init( void )
{
    // The first thing we need to do is to disable the watchdog timer.
    WDT_A_hold(WDT_A_BASE);

    SetupIO();
    SetupClocks();
    return (1);
}

static void SetupClocks( void )
{
    // Start the external 32.768 KHz crystal
    UCS_setExternalClockSource(UCS_BASE, PFM_XT1_FREQ, PFM_XT2_FREQ);
    UCS_LFXT1Start(UCS_BASE, UCS_XT1_DRIVE3, UCS_XCAP_0);

    // Set the DCO rate and source
    UCS_clockSignalInit(UCS_BASE, UCS_FLLREF, UCS_XT1CLK_SELECT,  UCS_CLOCK_DIVIDER_1);

    UCS_initFLLSettle(UCS_BASE, PFM_DCOCLK_FREQ_KHZ, PFM_FLL_DCO_RATIO);

    //Set ACLK 
    UCS_clockSignalInit(UCS_BASE, UCS_ACLK, UCS_XT1CLK_SELECT,  UCS_CLOCK_DIVIDER_1);

    //Set SMCLK
    UCS_clockSignalInit(UCS_BASE, UCS_SMCLK, UCS_DCOCLK_SELECT,  UCS_CLOCK_DIVIDER_1);

    //Set MCLK
    // UCS_clockSignalInit(UCS_BASE, UCS_MCLK, UCS_DCOCLK_SELECT, UCS_CLOCK_DIVIDER_1);
}

static void SetupIO( void )
{
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5+GPIO_PIN4);
    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P1, GPIO_PIN0);
}

------------------ Registers --------------------

UCSCTL0 = 0x1D98
UCSCTL1 = 0x0060
UCSCTL2 = 0x11E7
UCSCTL3 = 0x0000
UCSCTL4 = 0x0334
UCSCTL5 = 0x0000
UCSCTL6 = 0xC1CC
UCSCTL7 = 0x0411
UCSCTL8 = 0x0707

 

**Attention** This is a public forum