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.

Launchpad MSP430FR5969 and External crystall HFXT 16 MHz not working

I tested the launchpad board with internal DCO and all works ok.

Then I soldered an external 16 Mhz crystal with 18pf capacitors. I'm trying to run this code to test (with an oscilloscope) if the HFTX. There is some problem because my system produce an clock event every 13ms instead of 62.5ms. The strange thing is that if I remove the crystal the system still working with the same clock period.
Someone have some example with the MSP430FR59xx family ?

Thanks



This is my code: I'm not sure about PJ configuration

#include <msp430.h>



int main(void)
{



    //SET PORT

    PM5CTL0 &= ~LOCKLPM5;       // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings
    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog time
    

    //SET LED PORT

    P1SEL0=0b00000000;
    P1SEL1=0b00000000;
    P1OUT = 0;
    P1DIR = 0xFF;

     //SET HFXT PORT : not sure
    

      PJDIR = 0x00;

      PJSEL0|=BIT7|BIT6;
      PJSEL1=0x00;

    //SET CLOCK SURCE
    CSCTL0_H = 0xA5;       // Unlock CS registers
    CSCTL1_L=0b00000000;                                                   //DCO 1Mhz (not used)
    CSCTL2_L=SELS__HFXTCLK | SELM__HFXTCLK;     //SMCLK and MCLK source = HFXT
    CSCTL3_L=DIVS__1;                                                          //SMCLK/1 and MCLK/1
    CSCTL4_H = HFXTDRIVE1_H|HFFREQ1_H;               //Ser current crystal and frequence = 16Mhz

    //SET CLOCK

    TA0CCTL0 = CCIE;                                                   // TACCR0 interrupt enabled
    TA0CCR0 = 62500;                                                   // Value to compare with the timer to generate interrupt
    TA0CTL = TASSEL__SMCLK |ID__1| MC__UP;  // select SMCLK, Divide SMCLK/1, UP mode
    TA0EX0 = TAIDEX_0;                                                // DIV1 : So timer_CLK = SMCLK/1
    __bis_SR_register(LPM1_bits + GIE);               // Enter LPM0 plus ENABLE INTERRUPT




    while(1)
    {

    }
    return 0;

}



#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR (void)
{

   P1OUT^=BIT0;   //Toggle led P1.0

}

  • The code examples for your chip show how it's done correctly.

    Or you could simply use driverlib.

  • Look first to the example software and adjust yours according to this.
    Realize that you need a clock until your crystal clock is working properly, after this you can select the crystal clock and switch off the DCO.

    There are several ways to obtain example software for your device;
    • Go to the product page of your device and download the software examples.
    • If you are using Code Composer Studio (CCS) and have not already added MSPWare you can add MSPWare to your CCS installation (Add-on) trough ‘View\CCS App Center’.
    • Or if you don’t want to add MSPWare to CCS, go to: http://www.ti.com/tool/MSPWARE, from here you can download a standalone MSPWare version.
    • Or go to: http://www.ti.com/tool/MSPWARE and use the ‘MSPWARE-CLOUD’ version and download, unpack and import the specific files into CCS.
  • Hello user 4451984,

    you have to clear the pending oscillator fault flags after you initialized the HFXT. You can use the following code to do this.

    do { // Check for fault flags

    CSCTL5 &= ~(HFXTOFFG + LFXTOFFG);

    } while (CSCTL5 & (HFXTOFFG + LFXTOFFG));

    do { // Check for general OSC fault

    SFRIFG1 &= ~(OFIFG);

    } while (SFRIFG1 & OFIFG);

    After the flag are clear the fault-logic of the clock system will route the clock sources (LFXT or HFXT) to your selected clock paths (MCLK, SMCLK, ACLK).

    If the HFXT does not start you can try to increase the biasing of the HFXT with a higher HFXTDRIVE- setting.

    There is one thing more what you have to consider, when you want use MCLK with 16 MHz you have to enable the wait states for FRAM access. You can use copy the following code line at the beginning of your main-loop:  

    FRCTL0 = FWPW+NACCESS_1;

    Best regards,

    Michael

  • Thanks for all the response. I changed the code as Michael suggested ad the micro works very well.
    I think that the right code for the FRAM access is FRCTL0 = FWPW+NACCESS_1; (without the #).

    Best regards
    Riccardo
  • Hello Riccardo,

    you are right, C-Code doesn't need the #. I copied it from a ASM-File and there the # is necessary.

    The right code line is:

    FRCTL0 = FWPW+NACCESS_1;

    I've corrected it in the previous post.

    Best regards,

    Michael

**Attention** This is a public forum