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.

Setting up the Clock System (CS) in TI-RTOS for MSP432

Other Parts Discussed in Thread: SYSBIOS

Hi all,

How do I control the configuration of CS (MSP432) in TI-RTOS?

How do I set an MCLK/HSMCLK/SMCLK/ACLK rate of my choosing?

How do I specify the source for these clocks?  (e.g. MCLK comes from external oscillator, not DCO, e.g. ACLK comes from an accurate 32768 source so that the RTC keeps accurate time)??

There are lots of places where clock related items.  How do they interrelate?

  1.  The standard empty TI-RTOS project give you a file called MSP_EXP432P401R.c and in the Power section there is a power config structure.  I can only assume that the RTOS knows this structure exists and uses it if Power_Init() is called.  This structure allows me to select one of three existing "performance level profiles"  (combination of clock speeds, core voltages, wait states). If I want something different to those profiles, what do I do? Is there a way to change MCLK/SMCLK/HSMCLK/ACLK sources as well here?
  2. 2. If you are not using "device specific timer support" for timer module instances, you can set a clock period in the advanced settings of a timer module instance.  Why?
  3. In the BIOS module - runtime tab there is a CPU clock frequency setting
  4. There is a "ClockFreqs" module (bios_6_46_00_23/ti/sysbios/family/arm/msp432) that lets you set ACLK/SMCLK/HSMCLK frequencies, but this doesn't actually set the clocks to those frequencies, it just changes what is reported by ROV in the ClockFreqs section.

There are probably others that I have forgotten.... 

  • Hi Julian,

    You can modify the clock frequencies in PowerMSP432.c but you need to make sure that the core voltage value and flash wait states work with that frequency.  Also, make sure not to overclock the device.  There is no support in PowerMSP432.c for using the external oscillator.  DCO is the only supported clock source. The values in the PowerMSP432 performance levels were worked out by the MSP432 team to handle most cases.  There is a plan in a future release of TI-RTOS to make this more configurable by the user.

    The BIOS CPU frequency just tells BIOS what the CPU frequency is actually running at, but does not change the frequency.  This is important since it may be used in setting up the Clock timer period.  For example if the Clock module is using the lm4 timer (as for Tiva devices), the timer period is a function of BIOS.cpuFreq and Clock.tickPeriod.  If BIOS.cpuFreq does not reflect the actual frequency that the CPU is running at, the Clock ticks will occur at the wrong rate.

    The ClockFreqs for MSP432 is used in setting the msp432 Timer period.  It can also be used by other TI-RTOS drivers that need the ACLK frequency.

    I'm not sure I understand your question 2.  Is this something you are seeing in XGConf?

    Best regards,

    Janet

  • Hi Janet,

    When you say "There is no support in PowerMSP432.c for using the external oscillator", are you saying "don't do it", or "we haven't done it yet"? We would like to use the external oscillator and TI-RTOS, so can we just start the clock and tell the RTOS what the frequencies are, or doed the power saving code rely on the DCO, and we should avoid the external oscillator?

    Regards,

    Josh
  • Hi Janet,

    Thanks for your feedback. 

    Regarding question 2 - for the timer module, I can click on a link "device-specific timer support" on the Timer module settings:

    This takes me to the Timer-Module settings for the MSP432 which I enable.

    Once MSP432 timers are enabled I can create an instance, and in the advanced settings I have the option to select the clock source for the Timer (ACLK/SMCLK).

    • This setting is NOT available for instances of the HAL Timer module.
    • You may need to close and reopen the .cfg file to see the MSP432 specific timer module in the outline pane.

    It appears (looking at register configurations) that both the Clock module and the Timer modules use TimerA peripherals in the MSP432.

    If I can set the clock source for a Timer module instance (after all, at the hardware level, it is just a register setting), how do I do the same for the clock module?

    Cheers

    Julian

    Cheers

    Julian

  • Hi Josh,

    The PowerMSP432.c makes these assumptions (copied comments from source file):

    /*
     * Notes for initial implementation of Power_setPerformanceLevel()
     *
     * 1) There are three performance levels supported:
     *
     *    Level    MCLK (MHz)    HSMCLK (MHz)    SMCLK (MHz)    ACLK (Hz)
     *    -----    ----------    ------------    -----------    ---------
     *      0         12              3              3           32768
     *      1         24              6              6           32768
     *      2         48             24             12           32768
     *      3         48             48             24           32768
     *
     *    Only three of the peformance level constraints are supported:
     *
     *        PowerMSP432_DISALLOW_PERFLEVEL_0
     *        PowerMSP432_DISALLOW_PERFLEVEL_1
     *        PowerMSP432_DISALLOW_PERFLEVEL_2
     *        PowerMSP432_DISALLOW_PERFLEVEL_3
     *
     * 2) DCO is the only supported clock source (all clocks are derived from this;
     *    LF and HF XTALs are not used)
     *
     * 3) ACLK is fixed (and not included in the PowerMSP432_PerfLevel structure)
     *
     * 4) DCDC is assumed to be available
     *
     * 5) Hardware interrupts are disabled during the change of performance level
     *
     */

    So if you use the external oscillator instead of DCO, you would need to modify the PowerMSP432 code.

    Best regards,

    Janet

  • Hi Julian,

    I think the Clock module is only displaying properties of the ITimer interface, which is why you don't see the device specific Timer settings.  You can work around your problem of setting the input source for the Clock Timer by creating your own timer and setting the Clock.tickSource = Clock.TickSource_USER ("Application code calls Clock_tick" in XGConf).  The Clock module cdoc has an example of .cfg code to do this:

     *  // Tell the Clock module that YOU are providing the periodic interrupt
     *  Clock.tickSource = Clock.TickSource_USER;
     *
     *  // this example uses the ti.sysbios.timers.dmtimer.Timer module
     *  var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
     *
     *  // Change Timer 3 frequency to 24 Mhz from default if necessary
     *  Timer.intFreqs[3] = { hi:0, lo:24000000 };
     *
     *  // create a dmtimer config parameter object
     *  var timerParams = new Timer.Params();
     *
     *  // make sure you set the period to 1000 us (1ms)
     *  timerParams.period = 1000;
     *
     *  // custom dmtimer config parameters here...
     *  timerParams.twer.ovf_wup_ena = 1;
     *
     *  // Create the timer.
     *  // This example uses timer id 3.
     *  // Provide your own timer interrupt handler function.
     *  Timer.create(3, '&myTimerTick', timerParams);
     *  @p
     *
     *  In your 'C' code, add your timer interrupt handler and have it
     *  call Clock_tick(), which will perform all of the Clock module
     *  tick duties:
     *
     *  @p(code)
     *  #include <ti/sysbios/knl/Clock.h>
     *
     *  Void myTimerTick(UArg arg)
     *  {
     *       Clock_tick();
     *       ...
     *  }

    Best regards,

    Janet

  • G'Day Janet,

    Thank you for answering this question for me! This seems like a heavy solution given that the underlying hardware can solve the problem with just a register change (as we know from the Timer module), but it works and I'm happy to go ahead with it.

    Unfortunately, I've realized that this was another question that was bubbling in my mind, but was not related to my original question in this thread.

    Going back to your question about what I meant by point 2 in my original post.

    I guess I wasn't really asking 4 different questions - just listing 4 places where "clock frequency" related settings can be made and asking what the relationship between them is.

    For the second item in my list, if you create an instance of the Timer (ti.sysbios.hal) module, in the advanced settings, you can set an "External input clock frequency".

    So, to ask my original question a bit differently... It seems that PowerMSP432.c is the "root" for all clock settings. If I want a clock frequency (whether its MCLK, SMCLK, HSMCLK or ACLK) that is not available, is it enough to JUST change that file and recompile or do I need to go into the GUI and change some of the items in my list?

    Cheers
    Julian
  • Hi Julian,

    You can change the clock frequencies in PowerMSP432.c and not need to change anything in the GUI.  The PowerMSP432 module changes the frequencies when setting the performance level, and then calls PowerMSP432_updateFreqs() (which calls ClockFreqs_setFrequency() for the different clocks).  If you're just changing frequencies in the PowerMSP432 performance level tables, then it looks like you don't need to call ClockFreqs_setFrequency(), since the Power module handles this.  So, as long as Power_init() is called in main() (before the Clock module iniitialization where the Clock timer frequency is needed), and you have the default Power configuration in your board file (Power.enablePerf = true), you don't need to do anything else.

    There may be one problem, though.  The Power module is assuming that the Clock timer is running off of ACLK, whose frequency stays the same for the various performance levels.  If you use SMCLK for the Clock timer, and the frequencies of SMCLK in PowerMSP432 change for the different performance levels, the Clock ticks will be off.   The Clock module assumes a fixed timer frequency.

    Best regards,

    Janet

  • G'Day Janet,

    > If you use SMCLK for the Clock timer, and the frequencies of SMCLK in

    > PowerMSP432 change for the different performance levels, the Clock

    > ticks will be off.

    Does this remain true if I use the  Clock.tickSource = Clock.TickSource_USER method to change the Clock tick source?

    Returning to a couple of earlier comments took from PowerMSP432.c

    * 2) DCO is the only supported clock source (all clocks are derived from this;

    *    LF and HF XTALs are not used)

    Can be problematic where accurate timing is required.  E.g. if you want to sample at accurate intervals, or if you want to provide an accurate clock for the RTC.  But I think we can get around this in our application.  

    * 4) DCDC is assumed to be available

    This might be a more serious problem for us.  We found (at least in RevB silicon) that the DCDC introduces a lot of noise to ADC measurements.  Is there any way to force use of the LDO?

    Finally, in my TI-RTOS install (v2.20.0.06 - seems to be the latest version) I only have 3 performance levels, while the snippet from PowerMSP432.c you included above has 4 levels (I don't have the SMCLK = 24MHz mode).  That is fine - you probably have a newer version.  In my install, the highest performance level uses a flash wait state setting of 2, but my understanding is that RevC silicon works with a flash wait state setting of 1.  I guess it has been left at 2 for compatibility, but it leaves a little performance on the table.    Do you see any harm in changing the flash wait state setting? 

    Thank you for all your feedback over the last few days.  It's been invaluable.

    Julian

  • Hi Julian,

    The answer to your first question is "yes".  I'm not sure about your questions regarding the use of LDO and changing the flash wait states, though, so I'll see if I can find somebody to answer those questions.

    Best regards,

    Janet

  • Hi Julian,

    I just discussed your remaining questions with our local MSP432 expert.  It looks like you may be able to just replace AM_DCDC_VCORE0 and AM_DCDC_VCORE1 in the PowerMSP432_perfLevels[] table with AM_LDO_VCORE0 and AM_LDO_VCORE1.  It looks like the MSP432 driver lib APIs support that.  We haven't tried that, though.  We use DCDC because it is more efficient, but yes, it could introduce noise.

    You should be able to use 1 for the Flash wait states for the "red" MSP432 boards.  In newer versions of PowerMSP432.c we have flash wait states of 1, since we no longer support the older "black" MSP432 boards.

    Best regards,

    Janet