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.

MSP430 - UCS: How does the register DCORSEL needs to be if using FLL?

Other Parts Discussed in Thread: MSP430F5529

Hello readers!

At the moment I try to understand how to use the Unified Clock System (UCS) on a MSP430F5529.

These are my two possible aims:

XT2 = 220Hz    -->    FLL   -->    SMCLK = 216Hz

or

XT2 = 215Hz    -->    FLL    -->    SMCLK = 220Hz

 

This is what I think that I understand:

If FLL is enabled...

-   fDCOCLK  can be selected by the related bytes of the formula  fDCOCLK = D * (N + 1) * fFLLREFCLK / n     [SLAU208G, users guide, P.93].

-   DCO and MOD are changing all the time automatically up to the difference between FLLREFCLK and DCOCLK.

 

Questions:

-  If FLL is enabled: How does DCORSEL needs to be selected?

--> Can I select then any of the 8 possible DCO frequency ranges or does it needs to be a specific DCO frequency range?

 

Many thanks in advance!

  • Teh second of your two possible aims comes closer to the truth. Yet 'SMCLK' is wrong there. 'DCOCLK' is the key.

    The basic intention of the FLL is to compare an unstable, but adjustable high-frequency signal to a stable, fixed low-frequency source (such as a clock crystal) and adjust the high frequency source based on this comparison.

    The high frequency DCOCLK is divided by (N+1) and compared to the REFCLK signal, which may be LFXT1 or REFO (if available. and I don't think XT2 is a possible reference).

    Depending on the comparison result (it's not exactly a comparison, rather a two-trigger up/down counting), the DCO tap and the modulation bits are incremented or decremented.

    After some time this results in the DCO being switched between the setting that delivers a frequency above the desired one and the setting that gives less than expected, in average the exact frequency.

    Bob Marley said:
    If FLL is enabled: How does DCORSEL needs to be selected

    it should be selected so that the desired resulting DCO frequency is well in the range of frequencies provided by this RSEL setting. A deeper look into the datasheet about which is the guaranteed range of resulting DCO frequencies for a specific RSEL setting (not the overall min/max but rather the max of the min and the min of the max). For each target frequency there exists at least one (often two) DCORSEL settings which under all circumstances and with all production tolerance can be reached with one of the DCO taps. You should ensure that the maximum DCO tap is excluded form this calculation, as the modulation mechanism works by temporarily incrementing the DCO tap, which is impossible if you're already on the highest.

    The FLL will not touch the DCORSEL setting, so it is up to you to pick a proper one.

    Bob Marley said:
    Can I select then any of the 8 possible DCO frequency ranges or does it needs to be a specific DCO frequency range

    Every one can be chosen,  in which the desired freuency is reachable under all circumstances . Usually only one or two will meet this criterium.

    e.g. if the datasheet tells that RSELx with DCO0 ranges from 3 to 30 MHz, and with DCOmax ranges from 50 to 120MHz, then only 30 to 50 MHz can be reache dunder all circumstances. Also, since the highest DCO tap shouldn't be used (and the lowest too, as this will flag an oscillator fault, if you care for this flag), the RSELx should only be picked if the destination frequency is between 36 and 40MHz.

    Well 36MHz is too much for SMCLK anyway, but with the DCO prescaler, it would be allowed 18MHz for 54xx devices.

    Then DCOCLK or DCOCLKDIV (with prescaler) can be assigned to MCLK/SMCLK/ACLK.

  • Thanks, Jens-Michael!

    I think you took me back on the right road!

     

     

    This is my example how I would chose relating to my project:

    My source will be XT2 = 220Hz. My aim is to get the frequence for MCLK as high as possible.

    Steps:

    - Choosing the right range of frequency by DCORSEL (There the desired frequency must be between DCO0 and DCOmax --> DORSEL=6 --> 10.7MHz ... 39.0MHz).

    - Selecting the exact  frequency that is desired using FLL (n=1, N=24, D=1, see formula mentioned above)  -->  fDCOCLK = (24+ 1) * 220Hz = 17.8MHz

    - Check: ... Yes, fDCOCLK is within the allowed range of  ACLK, SMCLK & MCLK.

     

     

    Questions:

    -  What are the maximums for MCLK, ACLK and SMCLK?  - I only found what is written on p.49 of the datasheet (SLAS590B), that MCLK can be up to 25MHz.

    -  Does  fDCOCLK has got a maximum?   -  Besides the point that it should fit to SMCLK, MCLK and ACLK (at least after using DIVS, DIVM or DIVA).

    -  Is the use of FLLN in my calculation correct?

     

    Thanks again Jens-Michael!

     

  • DORSEL6 would indeed be my first choice too - just the worst-case range isn't 10.7..39 but rather 12..35 if you omit DC=x = 0/31 :)

    An alternative would be DOCRSEL7, going for 50MHz DCO and dividing by 2 (giving you 25MHz clock, since you wanted as fast as possible). It reduces the jitter introduced by the modulation.

    The maximums of all clocks are 25MHz on this MSP. All peripherals working with a clock have a minimum pulse length of 20ns, which gives (for one high and low pulse per clock cycle) 40ns cycle length = 25MHz.

    Bob Marley said:
    Does  fDCOCLK has got a maximum

    Sure it has. It's as high as the DCO gets :) Actually the DCO is an analog circuit and subject to signal attenuation and oscillation waveform distortion rather than digital edge limitations. So there is no sharp maximum frequency.
    The datasheet tells that the DCO can go as high as 135MHz on some devices, but at least 60MHz.

    DCOCLK is just the name of the digital signal that is output from the DCO circuit. So it has the same limitations (or capabilities) as the DCO itself. The usage of the DCO or OSC suffix is a bit spongy for historical reasons. What is a clock, what an oscillator... some peripherals accept clocks and oscillators as well (e.g. the WDT or the ADC), others convert oscillators into clocks, blah, blah, blah :)

    p.s.: my datasheet revision is D and maybe there's already E (I don't use this processor anyway), so maybe you should update your library :)

  • Hello Jens-Michael, hello all other readers!

    I think today I found a limitation for fBCOCLK, but maybe I am wrong. I would be interested about what you will write.

     

    Today I made some tests on the oscilloscope, trying to learn more about how the UCS works. Therefore I used the example code from TI.

    Used example code:

       The program "MSP430F552x_tb_10.c" is creating PWM-signals on 3 different pins, using no ISR but hardware.

    My changes in the code:

       By using this code I tried to find out how to show ACLK, SMCLK or MCLK as output on the related pins (e.g. P2.2 -> SMCLK or P7.7 -> MCLK).

       My CLK-Source should be XT1 (1MHz).

    Results:

       At first I could not find any clock-signal on the oszilloscop but since I enabled MCLK, ACLK or SMCLK with SELA_5, SELM_5 or SELS_5 I found the right signal.

       As the code produces PWM-signals on different pins without enabling MCLK, ACLK or SMCLK (by SELA, SELM, SELS)

    my converse argument is that

       if producing PWM-signals just by uC-hardware then there is no way to use the dividers DIVS, DIVM or DIVA which means that DCOCLK should not be too high.

     

    Questions:

    -  Is my conclusion right?   (converse agrument)

    -  By the way: Can I damage the uC by using a too high CLK (e.g. DCOCLK)? - Because if not, then I don't need to ask about something like that any more and I could find it out on the  oscilloscope on myself.

     

    Thanks again for your answer (and hints)!

    -  On Monday I will do some further investigations.

     

     

  • I think you should take another look atht he description of the clock module in the users guide.

    ACLK, MCLK and SMCLK are intermediate signals derived from a clock source and with a programmable divider.
    The tiemr hardware is either sourced by ACLK, SMCLK or external, with an additional divider.
    When producing PWM signals using the timer CCR registers, the PWM period is based on the CCR0 value as a coutn of tiemr ticks per PWM period. The timer ticks are based on a clock source (SMCLK or ACLK or external) divided by the ID setting. And SMCLK/ACLK are derived from an oscillator divided by the DIVA and DIVS settings (and DIVM for MCLK)
    Oscillators for all three clocks may be VLO, REFO, LFXT1, XT2, DCO or DCODIV.

    As a default, ACLK is sourced from XT1CLK (Which m,ay be 0Hz) and MCLK and SMCLK are driven by DCOCLKDIV. Your SELx_5 setting switched them to XT2, which is much higher. Anyway, MCLK and SMCLK do have a clock intially, yet it is a relatively slow one.
    (Well, with MCLK not having a clock, your program wouldn't be executed at all).

    Bob Marley said:
    Can I damage the uC by using a too high CLK (e.g. DCOCLK)

    Unlikely. Exceeding the allowed frequency range will make it running unstable up to complete failure, but after a reset, it should be okay again.

    BUT there is a chance for locking the device for JTAG usage: if your code executes and sets the clocks too high before the JTAG programmer can kick in, ther eis a chance that it will crash and not respond to JTAG anymore. It's rather unlikely for clock setting - the voltage supervisor can create such a situation easily, as it won't reset on a reset signal, only at power-on, but it is a possibility. In this case, usign the BSL will allow you to access it again, since the clock programming is reset on a reset signal and the BSL will kick in before your code is executes and crashes the device once more.

  • Hello Jens-Michael Gross,

    (of course) you are right again! It is also written in the line in the code next to the last from where the clock signal comes from:

      TBCTL = TBSSEL_2+MC_1; // SMCLK, upmode

    Thanks again for all your answers!!

     

    PS: I will ask a new question within a new post so it will be easier for others to find for what they are looking for.

**Attention** This is a public forum