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.

TMS570LS3137 RTI systick

Other Parts Discussed in Thread: HALCOGEN

Hello,

I am sorry for asking silly question but I need your help. I would like to know how to convert RTI systick to time (ms/ns).

I am using rtiGetCurrentTick(rtiCOMPARE0); which is available as unsigned rtiGetCurrentTick(unsigned compare) in rti.c and i get some value but i don't how to convert that into time (millisecond or nanosecond).

My intention is to find how much time does it takes to execute/initialize a functionality (like ADC, CAN, I2C, etc...) and i am using "rtiGetCurrentTick" as time-stamp.

Following are the settings which i am using:

RTI1CLK Counter0 : 

RTI1CLK = 80Mhz

Counter Frequency = 10 Mhz

Actual counter output clock frequency = 10Mhz

(Compare 0)  Actual period = 1millisecond

(The above values are set using HalCoGen tool)

  • Solomon,

    (1) This is no tool to directly covert cycle counts to time units. You need to do it manually by your self.

    (2) Another option is to toggle a GIO pin and and use a scope to measure the time.

    Thanks and regards,

    Zhaohong

  • Hello:

    You can also use PMU for this purpose. Please take a look at the following app note:

    http://www.ti.com/lit/an/spna138a/spna138a.pdf

    Regards,

    Enrique

  • Hello,

    I am trying with rti-ticks rtiGetCurrentTick(rtiCOMPARE0) to get current ticks. My intention is to find how much time it takes to execute a function. 

    This is what i assume.

    RTI1CLK = 80Mhz

    Therefore, it takes 12.5 nanoseconds to execute 1 RTI-Tick.

    Is my assumption correct? Also, is it RTI1CLK i have to consider or is it GCLK/ HCLK which is 160Mhz?

  • Samuel,

    Nope.  80MHz is the input clock to the RTI.

    There is a prescaler that has a min. divide ratio of 2.. So the fastest that the RTI counter can run is 40MHz in this case.

    But you might have configured this for an even larger value.  HalCoGen defaults to 10MHz I think.  It also has a graphical representation of the chain of dividers and shows you the frequency at each point.

    The Compare is compared against the free running counter in the RTI, and the Free Running counter is clocked by the prescaled clock.  

    When you say 'tick' that is usually an interrupt based on some (large) number of RTI clocks so that the interrupts occur at a rate of maybe 1ms or so ...   If you are really using the RTI Compare 0 to count cycles the resolution is pretty coarse.


    To get rid of all this abmiguity we recommend using the PMU's cycle counter.  This is a very simple way to count CPU clock cycles and you avoid having to understand the scale factors involved w. RTI.  Plus the RTI takes quite a few cycles to read believe it or not and it can be more disruptive to insert reads to an RTI inside a program because a pointer to the RTI is needed.   The PMU is a special function register and doesn't need a pointer to be read from. 

  • I did the following.

    /* Initialization*/

    _pmuInit_();

    _pmuEnableCountersGlobal_();
    _pmuSetCountEvent_(pmuCOUNTER0, PMU_CYCLE_COUNT); // PMU_CYCLE_COUNT > PMU_INST_ARCH_EXECUTED


    /* Measurement Time Compensation */
    _pmuResetCounters_();
    _pmuStartCounters_(pmuCOUNTER0);
    rawCycle[48] = _pmuGetEventCount_(pmuCOUNTER0);
    rawCycle[49] = _pmuGetEventCount_(pmuCOUNTER0);
    MesComp = rawCycle[49]- rawCycle[48];

    /** - Initialize SCI Routines to receive Command and transmit data */
    rawCycle[0] = _pmuGetEventCount_(pmuCOUNTER0);
    sciInit();
    rawCycle[1] = _pmuGetEventCount_(pmuCOUNTER0);
    PMU_Cycle = (rawCycle[1]- rawCycle[0]) - MesComp;

    /** - Configure NHET for PWM application */
    rawCycle[2] = _pmuGetEventCount_(pmuCOUNTER0);
    hetInit();

    _pmuStopCounters_(pmuCOUNTER0);
    rawCycle[3] = _pmuGetEventCount_(pmuCOUNTER0);
    PMU_Cycle = (rawCycle[3]- rawCycle[2]) - MesComp;

    Is this correct?