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.

About the clocks in MSP430

Other Parts Discussed in Thread: MSP430G2231

Hi guys,

I'm just a beginner regarding the MSP430 MCU and I'm currently following the workshop tutorial for the MSP430G2231 LaunchPad Development Tool.

I notice that there is many clock that can be use inside:

a) VLO

b) DCO

c) External crystal

d) ACLK

e) MCLK

f) SMCLK

How do I know which to choose from for which application?

  • Hello,

     

    for me as a beginner this was also kind of a weired expirience, generally you can choose whatever frequency source you want to power youre mcu or youre adc or timers or extern clocks, etc...

     

    But once you get more detailed insight of youre peripherals and attached devices like external ADCs or perhaps some PWM signals you want to generate, you will need certain frequencies for youre purposes and then you will learn that some clock sources are higher or lower in frequency than others, or some are really stable and some vary a lot.

     

    So for example i had to build a real time clock, so i needed a really stable ca. 32kHz clock so that my clock wouldnt go wrong after a day, but rather after 10 years :)

    So i found out that using the internal 32kHz source wouldnt work for me, i had to attach a 32kHz source on an external Pin and use this one as my source for the RTC ( real time lcok).

     

    No back to youre questions, as i see this, DCO and VLO are internal oscillators, those are generated by the MSP himself, so they are not that stable but they will work if you dont have a lot expectations on accuracy etc..

     

    I think youre internal oscillation cannot be that high , so if you want to be very fast like 25 MHz you will have to attach a external crystall which generates 25 MHz instead of youre internal onces.

     

    Now ACLK, MCLK, SMCLK are clock sources for youre MSP peripherals, you can define those sources in registers, you have to read a lot in the family user guide for youre device in order to understand that properly.

     

    So for exmaple you define youre extern 25 MHz crystal to MCLK and youre internal VLO ( very low oscillator ca. 32kHz if you define it that way) for ACLK, now you can use either MCLK or ACLK as source for TImerA, or TimerB or ADC_A, etc, and thos eperipherals will work faster or slower.

     

    Hope i hepled you a bit, but to get that straight you will have to study the FamilyUserGuide, in there you will have everything :) but of course it is hidden when you first look at it

     

    With regard,

    Seb

  • seb said:

    Hello,

     

    for me as a beginner this was also kind of a weired expirience, generally you can choose whatever frequency source you want to power youre mcu or youre adc or timers or extern clocks, etc...

     

    But once you get more detailed insight of youre peripherals and attached devices like external ADCs or perhaps some PWM signals you want to generate, you will need certain frequencies for youre purposes and then you will learn that some clock sources are higher or lower in frequency than others, or some are really stable and some vary a lot.

     

    So for example i had to build a real time clock, so i needed a really stable ca. 32kHz clock so that my clock wouldnt go wrong after a day, but rather after 10 years :)

    So i found out that using the internal 32kHz source wouldnt work for me, i had to attach a 32kHz source on an external Pin and use this one as my source for the RTC ( real time lcok).

     

    No back to youre questions, as i see this, DCO and VLO are internal oscillators, those are generated by the MSP himself, so they are not that stable but they will work if you dont have a lot expectations on accuracy etc..

     

    I think youre internal oscillation cannot be that high , so if you want to be very fast like 25 MHz you will have to attach a external crystall which generates 25 MHz instead of youre internal onces.

     

    Now ACLK, MCLK, SMCLK are clock sources for youre MSP peripherals, you can define those sources in registers, you have to read a lot in the family user guide for youre device in order to understand that properly.

     

    So for exmaple you define youre extern 25 MHz crystal to MCLK and youre internal VLO ( very low oscillator ca. 32kHz if you define it that way) for ACLK, now you can use either MCLK or ACLK as source for TImerA, or TimerB or ADC_A, etc, and thos eperipherals will work faster or slower.

     

    Hope i hepled you a bit, but to get that straight you will have to study the FamilyUserGuide, in there you will have everything :) but of course it is hidden when you first look at it

     

    With regard,

    Seb

     

    Thanks for the explanation.

    I really need a lot of studies on the user manual. But sometimes I really don't understand what it is saying.

    Could you explain further about the difference of ACLK, MCLK and SMCLK?

     

  • There are many clock sources (such as VLO, DCO, external crystals, etc.) each with its merits and limitations.

    But ACLK, MCLK, and SMCLK are clock delivery routers, not clock sources. You can put the clock source directly on a router, you also have the option of divide the frequency (by 2, 4, or 8) of the clock source before it is put on a router.

    MCLK is used to deliver clocks to the CPU. Peripherals usually can pick between SMCLK and ACK.

    For example, if you want DCO to source the clock for the CPU, you have to put the DCO clock on the MCLK router. If you want to use 32kHz crystal clock for a Timer, you have to put that 32kHz clock on the ACLK router and tell the Timer to use ACLK.

  • Steven Gan Teck Yik said:
    I notice that there is many clock that can be use inside:

    Not exactly.
    There are clocks and there are oscillators.
    VLO, DCO, REFO, ADCOSC and FLASHOSC and two external oscillators XT1 and XT2 are oscillators that provide a raw frequency. Not all of them are available in every device.

    Then there are the clocks. MCLK, SMCLK and ACLK. MCLK is the CPU core clock, the other two are for usage as clock signals in teh various hardwar emodules.

    You can configure the clocks to be sourced by a selection of the oscilaltors (it depends on the clock module of the particular MSP).
    But after you have configured the clock module, you only deal with SMCLK, MCLK and ACLK. It makes code prtable across devices which have different oscillators but the same hadrware mdoule.

    There are some exceptions. Some hardware modules have their own optional oscillator, ADCOSC for the ADC10/ADC12/SD, and the flash controller on newer MSPs has only its internal oscillator for operation (older ones used SMCLK or ACLK).
    And on newer MSPs, the watchdog can directly use the VLO as alternative to SMCLK and ACLK. But most modules use SMCLK or ACLK, no matter where they get clocked from.

    A typical setup is to have MCLK running on teh required operating frequency (if you need heavy processing power, then a high frequency, if not, then a lower one), SMCLK provides a clock signal suitable for all communicaiton or high-speed timing needs and ACLK being a low frequency signal, e.g. powered by an external watch crystal, to provide a stable and precise timing when the cpu is in low power mode.

    Personally, I don't need a slow low power clock, so I have MCLK and SMCLK at maximum speed and ACLK on 1MHz. THis is sufficient for all features I use, since most modules have an additional internal divider for ACLK and SMCLK.

    Which oscillator to use depends on your requirements:
    VLO is slow and inprecise but consumes virtually no power. So if you don't care if you will wakeup in 10 or 20 seconds, you can use it for sourcing ACLK and clock the wakeup timer with it. It is not suitable for any kind of timing-critical operation, including UART transfers.

    REFO is a cheap replacement for a 32768Hz crystal, if you don't mind it much higher tolerance. It consumes more power than VLO, is not avialable on all devices, and can be used for 9600Bd transfers too.

    DCO is an inprecise but adjustable oscilaltor for a really wide range of frequencies. Without calibration, you don't know in what a frequency a certain setting results. But it is available without external hardware, and on many MSPs there are claibraiton values that tell you which setting on this specific MSP will result in ~1MHz or ~8MHz frequency.
    On system start, MCLK, and therefore the CPU r,uns on a default DCO setting which on many MSPs is somewhere in the 1MHz range.

    XT1 and XT2 are the oscillators of choice if you want precise frequencies. On older MSPs, there is a limitation about what clock (SMCLK/ACLK) can be attached to wich XT. On others, they are exchangeable. However, XT2 is for high-speed crystals only, while XT1 supports low-power low frequency watch crystals with 32768Hz with internal load capacitors, as well as (not on all MSPs) high frequency crystals.

    The choice is yours.

     

  • old_cow_yellow said:
    But ACLK, MCLK, and SMCLK are clock delivery routers, not clock sources. You can put the clock source directly on a router, you also have the option of divide the frequency (by 2, 4, or 8) of the clock source before it is put on a router.

    Why do we divide the frequency of the clock source?

    old_cow_yellow said:

    MCLK is used to deliver clocks to the CPU. Peripherals usually can pick between SMCLK and ACLK.

    I see.

    Is it that MCLK is for the frequency of main loop in the c coding?

    Then, how do I pick between SMCLK and ACLK? What is the pro and cons?

    And I found out that there's TACLK. What is this clock now then?

  • Steven Gan Teck Yik said:
    Is it that MCLK is for the frequency of main loop in the c coding?

    Well, this and anything else done by the CPU. It's the CPU core clock signal. One tick, one CPU operation. No ticks, no CPU operations at all.

    Steven Gan Teck Yik said:
    Then, how do I pick between SMCLK and ACLK? What is the pro and cons?

    See the clock module description in teh users guide.

    SMCLK and ACLK can usually both be selected as sources for every hardware module that requries a clock. However, on older MSP families, SMLKC was unable to be sourced by XT1 and ACLK was unable to be sourced by XT2.
    Even on the latest MSPs, ACLK has a special fallback functionality: if it is source by an LF crystal on XT1, and this crystal fails, it will fall back to REFO oscillator automatically, while SMCLK won't. (and MCLK falls back to DCO, which is always available).

    Steven Gan Teck Yik said:
    And I found out that there's TACLK

    TACLK is an optional external clock input for TIemrA (there might be also TBCLK etc.). It is an external signal that can be used to make the timer count its pulses (turnign the tiemr into a counter), or to run synchronized to an external clock, e.g. for creating a synchronized PWM signal for external devices requiring this. TACLK cannot be used for anything else than for counting up the TimerA register TAR.

    If using the serial hardware in slave mode, there might be a SCLK input as well, that synchronizes the synchronous data transfer in SPI or I2C mode. It's module specific and described in detail in the module description in the users guide.

  • I see.

    I know that the default frequency for ACLK which uses VLO is 12KHz. For MCLK and SMCLK which use DCO the default frequency is the same for both right? I read some say 1MHz and some say 8MHz. What is the correct value?

     

  • I see.

    I know that the default frequency for ACLK which uses VLO is 12KHz. For MCLK and SMCLK which use DCO the default frequency is the same for both right? I read some say 1MHz and some say 8MHz. What is the correct value?

     

  • It is in the data-sheet. About 1.1 MHz

  • Don't trust that 12 KHz number for anything other than a very rough estimate.  The actual value will vary by chip and by input voltage (higher=faster).  I tested three chips with input voltages ranging from 2.0V to 3.5V and found one with VLO frequencies going from 10.3 to 10.9 KHz, one from 8.84 to 9.44 KHz, and one from 11.47 to 12.18 KHz.

  • Peter Bigot said:

    Don't trust that 12 KHz number for anything other than a very rough estimate.  The actual value will vary by chip and by input voltage (higher=faster).  I tested three chips with input voltages ranging from 2.0V to 3.5V and found one with VLO frequencies going from 10.3 to 10.9 KHz, one from 8.84 to 9.44 KHz, and one from 11.47 to 12.18 KHz.

    I see. How bout DCO? What is DCO default frequency?

  • Steven Gan Teck Yik said:
    I see. How bout DCO? What is DCO default frequency?

    It has no default frequency. Teh DCO is not calibrated and varies across individual devices, with temperature and with supply voltage.

    The users guide tells you teh default configuration (see teh clock module register settings, DCOx, MODx and RSELx bits) for this MSP family, and the device datasheet will tell you in which frequency range this settign will fall for this particular MSP.

    Some MSPs have calibration data stored somewhere, which has been measured at production time. If so, you can use it for setting the DCO to a specific frequency (1MHz, sometimes 2,4,8 too) on a specific supply voltage and temperature (again, see the datasheet for details, usually 3V and 25°C)

**Attention** This is a public forum