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.

TMS320F28386S: Timer documentation questions

Part Number: TMS320F28386S
Other Parts Discussed in Thread: SYSCONFIG

Some timer documentation seems inadequate, incomplete, or maybe wrong.

For function CPUTimer_setPreScaler()

cputimer.h states

//! This function sets the pre-scaler value for the CPU timer. For every value
//! of (prescaler + 1), the CPU timer counter decrements by 1.

What does that mean?

One of the examples states:

    //
    // Set pre-scale counter to divide by 1 (SYSCLKOUT):
    //
    CPUTimer_setPreScaler(cpuTimer, 0);

What does that mean? And what is SYSCLKOUT in this context.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For function CPUTimer_reloadTimerCounter()

cputimer.h states:

//! This function reloads the CPU timer counter with the values contained in
//! the CPU timer period register.

Why? When is the needed? Isn't the value set by CPUTimer_setPeriod()?

Thanks,

JH

  • Hello John,

    cputimer.h states

    //! This function sets the pre-scaler value for the CPU timer. For every value
    //! of (prescaler + 1), the CPU timer counter decrements by 1.

    What does that mean?

    The way the prescaler works is like an extra counter on top of the existing timer. Normally, the CPU timer decrements the TIMH:TIM register (loaded with the period). When using a prescaler however, the value PSCH:PSC (which is the prescale value loaded from TDDRH:TDDR) gets decremented until it reaches 0. One cycle after PSCH:PSC reaches 0, the value of PSCH:PSC gets reset with TDDRH:TDDR and then the timer counter TIMH:TIM decrements by one. So it essentially slows down the timer by allowing the PSCH:PSC to reach 0 first before decrementing the CPU timer itself.

    One of the examples states:

        //
        // Set pre-scale counter to divide by 1 (SYSCLKOUT):
        //
        CPUTimer_setPreScaler(cpuTimer, 0);

    What does that mean? And what is SYSCLKOUT in this context.

    When it says the pre-scale counter is set to divide by 1, this means there essentially is no prescaler (since the value is set to 0, it will not be counting before the CPU timer gets to decrement). Essentially by adding a prescaler you're slowing down or dividing the frequency of the clock. Here, SYSCLKOUT is your system clock frequency. This comment is essentially saying that the counter will be using the system clock frequency speed to increment the counter. In other words, 1 clock tick is 1 counter tick.

    cputimer.h states:

    //! This function reloads the CPU timer counter with the values contained in
    //! the CPU timer period register.

    Why? When is the needed? Isn't the value set by CPUTimer_setPeriod()?

    The value of the period is set using the CPUTimer_setPeriod() function, but the CPUTimer_reloadTimerCounter() function sets the TRB bit in the TCR register. This loads the timer counter TIMH:TIM with the period so that it is essentially starting the counter from the beginning (the counter decrements the loaded period value). This bit also loads the prescale counter PSCH:PSC with the timer dividedown TDDRH:TDDR value.

    A lot of these answers I wrote here can be found in the "CPUTIMER_REGS Registers" section of the technical reference manual (section 3.14.8). If you have any more questions, let me know.

    Best regards,

    Omer Amir

  • Thanks again. I think it is section 3.15.8 now, in SPRU110D - updated July 2022

    This furthers my case for the need for a programmer's reference manual. I agree that there is a lot of valuable info in the register descriptions and I am an EE and I can parse them. But then one must use this info program register bits or hopefully find an accurate and detailed example that has a function call or macro to set the TRB bit and only by analyzing these calls can it be determined if they set the needed bits.

    I am a contract engineer now (actually full time at TI, 78 - 93) and nowadays most employers don't want to give you time to study TRMs in detail. For example in the past few years I was only able to get a position because I had prior experience with PIC32 or STM32 or such. TI could help people's learning curve and throughput by putting the commands and what they actually do in a programmers manual. Also I would not need to pester you good folks on the forum as much. You guys are great but you are not online on the weekends.

    So thank you Omer for all of your detailed help. It has been quite useful and made me more knowledgeable about this peripheral.

    Apologies for late reply, have been out sick.

    John

  • Hello John,

    I'm sorry to hear the difficulty with parsing through the reference manual. For future projects, I recommend using SysConfig to configure your peripherals. This tool provides a GUI for initializing peripherals using the driverlib functions. Once you add a peripheral, it does most of the basic initialization and allows users to configure the rest. It simplifies the settings you need to change and can provide descriptions/error checking that usually does not happen at compile time. I've attached an image of how the CPU timer and its generated code looks using this tool:

    Even if you don't want to use the GUI as a regular tool, you can still use it as a reference for when you want to know how to configure a peripheral with the driverlib functions (although I recommend using the GUI because it provides better ease-of-use).

    Best regards,

    Omer Amir

  • Thanks. Is SysConfig accessed via CCS or is it standalone?

  • You can use SysConfig within CCS to actually generate code that you can run directly, or you can use the standalone version (but this does not have the capability to run a program on a device by itself).

  • Thanks again.

    I am not finding much documentation for the tool. I did find an old forum post and created a .syscfg file and let it build. It created INTERRUPT_init() and CPUTIMER_init(), but I was also expecting a config file.

    Is there a user guide?

    John

  • Hello John,

    Here are some videos that walk through how SysConfig works and creating an example: https://training.ti.com/sysconfig-development-tool-c2000-real-time-mcus. The user guide can be found here: https://www.ti.com/lit/an/spracx3/spracx3.pdf?ts=1669918560321.

    Best regards,

    Omer Amir

  • OK, thanks. I was expecting the guide on this page:

    https://www.ti.com/tool/SYSCONFIG#tech-docs

  • Hi John,

    That page you linked is for SysConfig in general. That page is shared by other device families than just C2000, so that may be why this training information does not show up there, because it's C2000-specific. I can request that the people who manage TI's website add it to make it easier to find.

    Best regards,

    Omer Amir

  • Excellent, that would save both of us time.

    Thanks.