Part Number: MSP430FG6626
Tool/software: Code Composer Studio
Using the MSP430FG6626 with two crystals, I am having issues starting XT1CLK which is preventing me from using the RTC_B.
XT2CLK initialized correctly and driving MCLK and SMCLK at 16 MHz and 8 MHz respectively.
Although I don't plan to use ACLK and FLL, I had them configured to be driven by REFOCLK.
Clock Setup
static WORD16 debug;
static WORD32 smclkVal;
static WORD32 mclkVal;
static WORD32 aclkVal;
//
// Initialize
//
debug = 0;
//
// Port Select XT2
//
GPIO_setAsPeripheralModuleFunctionInputPin (GPIO_PORT_P7, PERIPH_IN_PORT7);
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P7, PERIPH_OUT_PORT7);
//
// Set VCore to 2 for 16MHz clock
//
PMM_setVCore(PMM_CORE_LEVEL_1);
PMM_setVCore(PMM_CORE_LEVEL_2);
//
// Initialize Source Crystal Frequencies: XT1 and XT2
//
UCS_setExternalClockSource(32768, 16000000);
//
// Initialize ACLK and Reference Clock (Won't be Used)
//
UCS_initClockSignal(UCS_ACLK, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1);
UCS_initClockSignal(UCS_FLLREF, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1);
//
// Clock Fault Initialization
//
UCS_clearFaultFlag(UCS_XT1LFOFFG | UCS_XT1HFOFFG | UCS_XT2OFFG);
//
// Turn On XT1
//
if(!UCS_turnOnLFXT1WithTimeout(UCS_XT1_DRIVE_3, UCS_XCAP_3, XT1_INIT_TIMEOUT))
{
// ***********************
// ***********************
// ***********************
// ***********************
// Timeout Always Occur
// ***********************
// ***********************
// ***********************
// ***********************
// Handle Error Case
debug++;
}
//
// Initialize XT2 (8MHz to 16MHz operation range)
//
if(!UCS_turnOnXT2WithTimeout(UCS_XT2_DRIVE_8MHZ_16MHZ, XT2_INIT_TIMEOUT))
{
// Handle Error Case
debug++;
}
//
// Configure MCLK and SMCLK to XT2 Source
// - Powers MCU Clock and Peripheral Clocks
//
UCS_initClockSignal(UCS_MCLK, UCS_XT2CLK_SELECT, UCS_CLOCK_DIVIDER_1);
UCS_initClockSignal(UCS_SMCLK, UCS_XT2CLK_SELECT, UCS_CLOCK_DIVIDER_2);
//
// Enable Global Oscillator Fault Flag
//
SFR_disableInterrupt(SFR_OSCILLATOR_FAULT_INTERRUPT);
SFR_clearInterrupt (SFR_OSCILLATOR_FAULT_INTERRUPT);
//TODO: NMI Clock-Error Free
//SFR_enableInterrupt (SFR_OSCILLATOR_FAULT_INTERRUPT);
//
// Verify Output Frequencies
//
smclkVal = UCS_getSMCLK();
mclkVal = UCS_getMCLK();
aclkVal = UCS_getACLK();
//
// Error Case(s)
//
if(smclkVal != (XT2_FREQ >> 1))
{
debug++;
}
if(mclkVal != XT2_FREQ)
{
debug++;
}
if(aclkVal != 32768)
{
debug++;
}
UCS_turnOnLFXT1WithTimeout() appears to always time out, as timeout value of 50,000 (and likely higher) will not work.
Using UCS_turnOnLFXT1() instead will result in an infinite loop (won't exit function call). Trying different DRIVE_X and CAP_X settings led to the same result.
I'd appreciate any help on this issue.