Jump to content
43oh

FRAM external crystal enable/troubles...


Recommended Posts

Hi everybody,

 

Just got my EXP430FR5739 experimenters kit and it works very nice. However, I soldered the external crystal on the board and getting the oscillator to run is not trivial. I have enabled the ACLK output on pin 2.0, but it reads 8911Hz instead of 32768Hz. Shorting the crystal does not do anything and the oscillator does not seem to be running from the crystal. Did I do anything wrong with configuring the oscillator? I also increased the drive strength of the oscillator to no avail.

 

I have included the following code in CCS4:

 

#include

#include "msp430.h"

 

void main(void) {

CSCTL0_H = 0xA5; // Unlock register

CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting

CSCTL2 = SELA_0 + SELS_3 + SELM_3; // set ACLK = XT1LF; MCLK = DCO

CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // set all dividers

CSCTL4 = XT2DRIVE_0 + XT2OFF_H + XT1DRIVE_0;

CSCTL0_H = 0x01; // Lock Register

PJSEL0 |= BIT4 + BIT5;

PJSEL1 &= ~(BIT4 + BIT5);

WDTCTL = WDTPW + WDTHOLD;

TA0CCR0 = 16383;

TA0CCTL0 = CCIE;

TA0CTL = TASSEL_1 + ID_0 + MC_3 + TACLR;

TA0EX0 = TAIDEX_0;

__enable_interrupt();

// _bis_SR_register(GIE);

P3DIR |= BIT4;

P2DIR |= BIT0;

P2SEL0 |= BIT0;

P2SEL1 |= BIT0;

while(1){

}

}

 

#pragma vector = TIMER0_A0_VECTOR

__interrupt void Timer0_A0_ISR(void)

{

P3OUT ^= BIT4;

}

 

I hope someone can help me. I'd love to have a accurate RTC.

 

Kind regards,

 

Eelco

Link to post
Share on other sites

Did you try looking at the TI examples for the FR5739? The register settings are little different than what you've set.

 

 CSCTL0_H = 0xA5;
 CSCTL1 |= DCOFSEL0 + DCOFSEL1;             // Set max. DCO setting
 CSCTL2 = SELA_0 + SELS_3 + SELM_3;        // set ACLK = XT1; MCLK = DCO
 CSCTL3 = DIVA_0 + DIVS_1 + DIVM_1;        // set all dividers 
 CSCTL4 |= XT1DRIVE_0; 
 CSCTL4 &= ~XT1OFF;

Link to post
Share on other sites

Thank you, I will try your suggestions, but I'm afraid it will not work, as I tried many different combinations.

 

I've been reading the family user manual and it is not really clear what to do. Did you find a working example?

 

I also read additional caps are needed for the crystal and I see some solder pads for additional caps.

 

Currently my blinking led is blinking very slow on the VLO.

 

Kind regards, Eelco

Link to post
Share on other sites

According to the fram family user guide the following statements are made regarding the LFXT1.

 

"As previously stated, XT1 is selected by default, but XT1 is disabled. The crystal pins (XIN, XOUT) are

shared with general-purpose I/Os. To enable XT1, the PSEL bits associated with the crystal pins must be

set. When a 32768-Hz crystal is used for XT1CLK, the fault control logic immediately causes ACLK to be

sourced by the VLOCLK, because XT1 is not stable immediately (see Section 3.2.7).

 

Status register control bits (SCG0, SCG1, OSCOFF, and CPUOFF) configure the device operating modes

and enable or disable portions of the clock system module (see the System Resets, Interrupts, and

Operating Modes chapter). Registers CSCTL0 through CSCTL6 configure the CS module."

 

I see the fault appearing, but I am not able to get the oscillator running.

 

Kind regards,

 

Eelco

Link to post
Share on other sites

Okay,

 

This solved the problem partially! The while loop waiting for LFXT1 to stabilize keeps on looping. However, pressing pause during debugging and continuing seems to do the trick and helps the oscillator to start oscillating. Now find a way to do this reliably without having to interrupt the running program.

 

I'm going to try the full source code to see if there are other things that aid stabilization.

 

Kind regards, Eelco

Link to post
Share on other sites

Okay,

 

The example you mentioned works great. I already was a bit disappointed that LFXT1 didn't work, but it does now. But now I need to understand what the difference is and why my code doesn't work. Any ideas?

 

#include "msp430.h"

void main(void) {

PJDIR = 0xFF;
PJOUT = 0;

// XT1 Setup 

PJSEL0 |= BIT4 + BIT5; 

CSCTL0_H = 0xA5;
CSCTL1 |= DCOFSEL0 + DCOFSEL1;             // Set max. DCO setting
CSCTL2 = SELA_0 + SELS_3 + SELM_3;        // set ACLK = XT1; MCLK = DCO
CSCTL3 = DIVA_0 + DIVS_1 + DIVM_1;        // set all dividers 
CSCTL4 |= XT1DRIVE_1; 
CSCTL4 &= ~XT1OFF;
P3DIR |= BIT4 + BIT5;
P3OUT &= ~BIT5;

do
 	{
	P3OUT |= BIT5;
   	CSCTL5 &= ~XT1OFFG;
                                           // Clear XT1 fault flag
   	SFRIFG1 &= ~OFIFG; 
 	}while (SFRIFG1&OFIFG);                   // Test oscillator fault flag

P3OUT &= ~BIT5;

WDTCTL = WDTPW + WDTHOLD;
TA0CCR0 = 16383;
TA0CCTL0 = CCIE;
TA0CTL = TASSEL_1 + ID_0 + MC_3 + TACLR;
TA0EX0 = TAIDEX_0;
__enable_interrupt();
//	_bis_SR_register(GIE);
P2DIR |= BIT0;
P2SEL0 |= BIT0;
P2SEL1 |= BIT0;
while(1){
}
}

#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR(void)
{	
P3OUT ^= BIT4;
}

 

And the code from the example:

#include "msp430fr5739.h"


void main(void)
{
 WDTCTL = WDTPW + WDTTMSEL + WDTSSEL_1 + WDTIS_4; // ACLK, 1s interrupts
 SFRIE1 |= WDTIE;                          // Enable WDT interrupt
 P1DIR = 0; 
 P1OUT = 0; 
 P1REN = 0xFF;

 P2DIR = 0; 
 P2OUT = 0; 
 P2REN = 0xFF;

 P3DIR = 0; 
 P3OUT = 0; 
 P3REN = 0xFF;

 P4DIR = 0; 
 P4OUT = 0; 
 P4REN = 0xFF;

 PJDIR = 0xFF;
 PJOUT = 0;

 // XT1 Setup 

 PJSEL0 |= BIT4 + BIT5; 

 CSCTL0_H = 0xA5;
 CSCTL1 |= DCOFSEL0 + DCOFSEL1;             // Set max. DCO setting
 CSCTL2 = SELA_0 + SELS_3 + SELM_3;        // set ACLK = XT1; MCLK = DCO
 CSCTL3 = DIVA_0 + DIVS_1 + DIVM_1;        // set all dividers 
 CSCTL4 |= XT1DRIVE_0; 
 CSCTL4 &= ~XT1OFF;

 do
 {
   CSCTL5 &= ~XT1OFFG;
                                           // Clear XT1 fault flag
   SFRIFG1 &= ~OFIFG; 
 }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag

 // Turn off Temp sensor
 REFCTL0 |= REFTCOFF; 
 REFCTL0 &= ~REFON;

 // Turn on LED 
 P3DIR |= BIT4;
 __bis_SR_register(LPM3_bits+GIE);

}


// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void WDT_ISR(void)
{
 P3OUT ^= BIT4;                            // Toggle P3.4 (LED)
}

Link to post
Share on other sites

I probably solved the problem thanks to gwdeveloper and some tweaking.

 

Moving the line "WDTCTL = WDTPW + WDTHOLD;" all the way up and moving some bit manipulations with respect to PORT3 after the oscillator initializations, makes a rocksteady 1s blinking LED.

 

Still not completely convinced, but a happy camper for now!!

 

Kind regards,

 

Eelco

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...