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.

TI-RTOS on MSP432 - Clock accuracy and configuration

Other Parts Discussed in Thread: SYSBIOS

G'Day all,

Sorry for posting so many questions of late.  I hope you can consider one more.


I understand that the Clock module uses a TimerA peripheral to keep track of time.

Digging through the registers, I see that SYS-BIOS sets up this peripheral to use ACLK, which is sourced by the LXFTCLK, which on the Launchpad comes is a 32.768kHz oscillator.

As a result, the resolution for the clock module tick period is 1/32768 sec (though the GUI allows setting in uSec resolution and doesn't warn you of the error!)

If you would like a reasonably accurate 1mSec tick, you won't be able to get it from the Clock module if its configured this way.  

Ideally I'd like to reconfigure the clock module to run off SMCLK instead of ACLK.  The default configuration set SMCLK to 12MHz, so if I set the TIMER ID divder to 4 and the IDEXT divider to 3 (or any other combination that gives me a divide ratio of 12) I get a 1MHz timer clock and now I can really can set the Clock module with 1uSec resolution (though I'd be happy with 10uSec or even 100uSec resolution). 

[I'm assuming here that SYSBIOS uses the TimerA in such a way that this change of timebase won't end up causing overflows given the 16bit compare registers].

Since the clock module sets the system wide tick period, every other function that takes a parameter in units of ticks (e.g. task_sleep(), semaphore_pend() etc) will also get the more accurate period.

Can I do this reconfiguration through the GUI (or the .cfg file), or do I have to do it in code?  I don't care if this breaks the Seconds module - I'm using the RTC for seconds anyway.

If I can't do this for the Clock module, can I be a bit more direct and instanciate a Timer in SYSBIOS and configure it as described above?


Cheers

Julian

  • UPDATE:

    I've found a way to create a separate 1mSec timer running off SMCLK.

    * Available products -> TI-RTOS -> Products -> SYSBIOS -> Scheduling -> Timer
    * Click on Device Specific Timer support
    * Check the "Add the MSP432-Specific Timer ...." check box.
    * Click on "Instance" at the top of the screen.
    * You will be presented with a screen where you can create/configure device specific timers.
    * Choose a Timer Id different to the one used for the Clock module
    * Under advanced settings, then clock settings you can set a clock source (I set SMCLK).
    * SYSBIOS takes care of setting prescalers and timer compare registers correctly (a little differently to what I described above, but the settings SYSBIOS uses give the right results).
    * Now your Period setting (in microseconds) will be accurately kept.

    The device specific timers I add don't seem to appear in the outline view. I have to click on Timer in the outline view then on Device-Specific Timer support to see the list of device specific timers.

    Is there a way to tell the Clock module to use a device specific timer in the same way? I tried creating a Device-Specific timer with the same Id number as I used for the Clock module, but, not surprisingly, that wouldn't compile.
  • Can you tell me what version of SYSBIOS you are using?  Then post the compile error you are seeing.

    You should be able to create a device-specific timer and have the Clock by hooked to this.
    I am not an expert on the MSP432 parts so I will get in contact with someone who knows more about this part and get back to you.

    Judah

  • G'Day Judah,

    I'm using TI-RTOS 2.14.3.28

    Please see attached screen shots for my clock configurations and errors.  I've attempted to map my device specific timer to the same Timer ID as I have set the clock module.




    Cheers

    Julian

  • Julian,

    I think whats going on is, internally Timer 0 is already being created and used by the Clock.

    Can you use Timer 1 instead?  And then in Clock change the "Timer Id" to be 1?

    Judah

  • Hi Judah,

    My goal here is to force the Clock module to configure its TimerA peripheral to run off SMCLK (12MHz) rather than ACLK (32768Hz) so that I can get more accurate 1mSec ticks.

    My naive attempt (above) was to create a device specific TimerA running off SMCLK, then telling the Clock module to use the same TimerA perhiperal.

    This approach is obviously wrong because it gives errors (Clock and timer modules can't use the same peripheral) - but what is the right way of acheiving my goal??

    In a similar vein, (and perhaps this should be a separate question to the forum) how do I get SYS-BIOS to use the HFXT rather than the DCO as the source for MCLK????

    Configuring clocks in MSPWare is dead easy - just a couple of CS_initClockSignal() commands.  In TI-RTOS it feels incredibly opaque. 

    As best I can work out, clock (CS) configurations can only be deduced by looking at the registers directly, and its not clear how these configurations can/should be changed.  I worry that simply adding CS_initClockSignal() calls is a bad idea because it might step on the RTOS' toes.


    Cheers
    Julian

  • Julian,

    My suggestion is create Timer 1 instead of Timer 0...so there's no conflict.

    Then point the BIOS Clock module to Timer 1 (The one you just created)

    Judah

  • G'Day Judah,

    How do I point the BIOS clock module to Timer 1?
    If I create a device specific timer using Timer ID1, then set the Clock module to use timer ID 1 as well, I get the same error.

    Cheers
    Julian
  • This is what the cdoc documentation says:

    If you want to use a custom configured timer for the Clock module's
    * tick source, use the following example configuration as a guide:
    *
    * @p(code)
    * var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    *
    * // Tell the Clock module that YOU are providing the periodic interrupt
    * Clock.tickSource = Clock.TickSource_USER;
    *
    * 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:

    Judah