Jump to content
43oh

SMCLK faulty on F2619?


Recommended Posts

I've been working on a high-altitude balloon for the last couple months. It is controlled by an MSP430-F2619. I wish I had a schematic to show you but I didn't make one and its complicated enough now that I'd rather just float this question out there without one and if we can't say without seeing them, oh well. So, here it goes!

There is a 5 MHz digital oscillator driving LFXT1 through XOUT (pin 9 on the 64-pin PM package).

 

Here's my clock and initialization code:

void init_clocks_and_io(void)
{
volatile u32 i;

WDTCTL = WDTPW + WDTHOLD;		// Stop WDT

// Set all unused pins to output to prevent floating inputs
P1DIR |= BIT1;
P1DIR |= BIT2;
P1DIR |= BIT3;
P1DIR |= BIT4;
P1DIR |= BIT5;
P1DIR |= BIT6;
P1DIR |= BIT7;
P2DIR |= BIT0;
P2DIR |= BIT1;
P2DIR |= BIT2;
P2DIR |= BIT3;
P2DIR |= BIT4;
P2DIR |= BIT5;
P2DIR |= BIT6;
P2DIR |= BIT7;
P3DIR |= BIT0;	
P3DIR |= BIT3;
P4DIR |= BIT0;
P4DIR |= BIT1;
P4DIR |= BIT2;
P4DIR |= BIT4;
P4DIR |= BIT5;
P4DIR |= BIT6;
P4DIR |= BIT7;
P5DIR |= BIT0;
P5DIR |= BIT1;
P5DIR |= BIT2;
P5DIR |= BIT3;
P5DIR |= BIT4;
P5DIR |= BIT5;
P5DIR |= BIT6;
P5DIR |= BIT7;


BCSCTL1 = 0x87 | XTS;	// Default reset + // XTS = high-freq mode
BCSCTL2 = 0x00;	// Default reset
BCSCTL3 = 0x30;	// Default reset + // Turn oscillator capacitor to ~1 pF + LFXT1S_3 = 11 digital input

do
{
	IFG1 &= ~OFIFG;					// Clear OSCFault flag
       for (i = 0xFFF; i > 0; i--)		// Time for flag to set
	{
		__delay_cycles(1);
	}
} while (IFG1 & OFIFG);

IFG1 &= ~OFIFG;		// Clear OSCFault flag

BCSCTL2 = 0xC0;	// SELS = DCO, SELM = 5MHz(MCLK -> 5 MHz)

init_UARTA0();
init_UARTA1();

__enable_interrupt();
}  /* init_clocks_and_io() */

 

In this way it works. But if at the 4th to last line, I make that BSCTL2 = 0xC8; SELS ->5MHz crystal on LFXT1, then this gets very unstable. If I just do a UART spam test (shown below), I see random bad characters. I also see SMCLK being disturbed if I scope its output on pin 5.5. The crystal, MCLK, or ACLK on the other hand show no sign of the disturbance (which appears as a jitter in the position of the square wave when viewed on an o-scope):

void main(void)
{
static int i;

i = 0x30;

init_clocks_and_io();

while (1)
{
	printf("%c", i++);
	__delay_cycles(5000);
	if (i > 0x39)
	{
		i = 0x30;
	}
}
}

 

I've also tried replacing the chip, replacing the crystal, fixing its voltage divider (which had V high below the minimum for 1 logic) etc.

 

Now if I just take my code and run UARTS off of ACLK and just ignore SMCLK and set it to the DCO, using this same crystal as the source for everything, my code runs perfectly. No crashes, no UART errors, nothing! What am I missing or did I find a flaw in the chip?

Link to post
Share on other sites

I appologize for the lack of commenting on those lines. I was worried that my IDE was doing weird things with bit logic and so just assigned values instead of ORing in constants.

 

I'll explain my expectations of what I have set in the registers.

 

# This sets XT2OFF to 1 making sure XT2 is not running. The "7" sets RSELx to 7 which is a range select for the DCO

BCSCTL1 = 0x87 | XTS; // Default reset + // XTS = high-freq mode

# This sets MCLK to DCOCLK with a divider of 1, sets SMCLK to DCOCLK with a divider of 1 and sets the DCO resistor to internal

BCSCTL2 = 0x00; // Default reset

# This sets XT2S to low speeds (its not used as per above), sets LFXT1S to a digital external 0.4 to 16-MHz clock source

# (assuming XTS is 1 which it is as set above), and XCAPx to 0 (~1 pF oscillator capacitor), and ignores the oscillator fault flags.

BCSCTL3 = 0x30; // Default reset + // Turn oscillator capacitor to ~1 pF + LFXT1S_3 = 11 digital input

 

When I set BCSCTL2 to 0xC8 this should do the following

# SELMx = 11, LFXT1CLK or VLOCLK with a divider of 1; the "8" sets SELSx to XT2CLK when XT2 oscillator present (which it is not in my understanding of this phrase; I do not have one installed though the chip allows for one). LFXT1CLK or VLOCLK when XT2 oscillator not present (so it should do this setting SMCLK to LFXT1CLK).

 

Hope that clears it up. Thanks!

Link to post
Share on other sites
There is a 5 MHz digital oscillator driving LFXT1 through XOUT (pin 9 on the 64-pin PM package).

 

I think that should be XIN (pin 8).

 

I can't find any specific statement in the MSP430 spec sheets that says that, but it is typical for connection of an oscillator module to a microcontroller.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...