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.

MSP430F6775A: DCO

Part Number: MSP430F6775A


Tool/software:

Hi,

  1. I would like to ask is the XT1 crystal oscillator flag possible to reset instantly or is it needed to wait. Cuz I have debug my program and it was fine like during debugging all flags were reset but when I restarted device the flag was set for that crystal. And I have noticed in examples it was cleared just like that with one while checking the DCO flag. So I am confused a little bit I have also used the DCO settle time. I have reset the flags after that but as I have said it is still on till I won't set much higher settle time. So am I missing something? Or is there any constant I should set the delay on while erasing the X1 flag?
  2. Is there any flag other critical flag that is better to check during runtime?
  • Hi Peter,

    Clearing pending interrupts is a way to make sure your device is in a known state in the beginning and if the cause to the flag is still present then the flag will get set again. If your settling time is too short then you could get the flag raised again.

    The wait time is used to make sure the DCO is stabilized before continuing MCU operation. You'll also need your stabilization time on an external crystal because you need the external crystal to settle, once it is powered (powering the crystal happens after the USCTL6 bit is turned on for the XT1). 

    The fault flags should be the one you check to verify the crystals have started properly.

    Regards,
    Luke

  • Hi Luke,

    So I should set up the XCAP and XDRIVE and than turn on external crystal with UCSCTL6 &= ~XT1OFF; and than I should wait till crystal stabilizes by continuously checking and resetting the

    UCSCTL7 & XT1LFOFFG than set up the DCO and FLL than check and reset the DCO Fault flag and XT1 Fault Flag again ? Something like that? The time I should wait also is not firmly set up for the XT1 like for the DCO I mean the DCO settling time = n x 32 x 32 x f_MCLK / f_FLL_reference? Can I use any number of cycles?
    Thank you for your reponse.
  • Hi Peter,

    Your crystal should have a start-up time, or you can wait a couple microseconds and do a binary search for the best time. A while loop check could work, but you're doing a compare operation and jumps instead of a _NOP. Your process flow of setting XT1 then DCO will work though.

    Regards,
    Luke

  • So the best way how to handle the waiting for the crystal to get started is to set some time using _delay_cycle(); ? I mean the compare and jump in while is not the best way I guess ? Or ?

  • Hi Peter,

    You can use delay_cycles, the cycle delay will be based off the MCLK and the settling adjustments won't cause any erroneous jump for this section. If you wait till XFT is settled then adjusted the DCO that would be the better method so you can have a stable crystal and delay_cycles can be mapped to an actual time.

    If you adjust the DCO then use delay cycles to wait for DCO to settle, the time won't be cycles*CLK frequency as the clk frequency would be adjusting over time to meet your targeted settings.

    Regards,
    Luke

  • Hi,

    Thank you for your answer. The time may vary for example due to temperature conditions so that is the reason why I have been waiting for crystal to start its operation using for loop and lower cycle rate with integer counter in loop. Isn't it better solution? I mean the XT1 may stabilize sooner or later. Or are there any side effects.

    int count = 50000;

    do
    {


    UCSCTL7 &= ~XT1LFOFFG;
    SFRIFG1 &= ~OFIFG;

    _delay_cycles(50);

    } while((UCSCTL7 & XT1LFOFFG) && --count);

    }

  • Hi Peter,

    There's a bit more processing going on here, my initial thought is this would work but I suggest testing with your crystal to verify. In your project, would you be able to wait for the worst case scenario for your temperature range and wait the max time? or does it change drastically for your crystal?

    Regards,
    Luke

  • Hi,

    I did not find any temperature drift details in crystal datasheet.

  • Hi Peter,

    You can put the crystals max time if you want to be extra careful, if your crystal doesn't list any start time then you can calculate based on the ESR and Load Capacitance as a base time but you may have to do an experimental on the start-up time to find what works for the system.

    We do have a Crystal Oscillators document as well that I do recommend reading - MSP430 Crystal Oscillators

    Regards,
    Luke

**Attention** This is a public forum