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.

TMS320C6748: Timer Problem

Part Number: TMS320C6748

TMS320C6748 Timer Problem.

  My question is about C6748 DSP processors tick count per second. I have external interrupt source which is sending pulse per second and my interrupt service routine (ISR) is triggered by this pulses. Every time this ISR runs, I measure system time via TSCL and TSCH registers. Each pulse has 1.000.000 microsecond interval as I said before but when I measure intervals between ISRs  intervals between these routines approximately 1.000.027 microsecond.

  •   I have tried several few things to fix this issue. For example; I move the functions I use to measure time to L2 cache. I read  ~1.000.000 microseconds for about 30 seconds but after 25-30 seconds I continued to get 1.000.027 seconds again.
  •  Also, I changed the PLL settings and started the processor with different clock frequencies. But there was no change.
  •  While I expected 1,000,000 microsecond between my interrupts, there are always values ​​of ~ 1,000,027 microsecond.
  • Also instead of measuring time intervals. I decided to measure the number of ticks for each second. For the 300 Mhz clock source, while the processor is expected to make about 300.000.000 tick, I always get values ​​like 300.008.500. I know that it cannot be expected  to make exactly 300,000,000 tick counts, but the average value is always much higher than 300,000,000 because it always counts more than it is expected to be 300,000,000. And that's the reason for the error in time intervals calculations.

 How can I solve this problem? Many thanks for interest.



 

  • Hi Yusuf,

    Just to make sure I understand your question, you have the ISR fired for every pulse which is @ 1 second rate. You are noticing the ISR spacing as 1,000,027 micro seconds.. and you are chasing the reason for additional 27 micro seconds right?

    Also instead of measuring time intervals. I decided to measure the number of ticks for each second. For the 300 Mhz clock source, while the processor is expected to make about 300.000.000 tick, I always get values ​​like 300.008.500.

    I am wondering, why are you expecting your clock source be a perfect clock? They would have jitter and if I read the above right, you are chasing the reason for 300,008,500 ticks. About 8500 ticks . Note that the TSC ticks for every CPU cycle.

    It makes me think you are running your CPU at 300,008,500Hz. Is it possible for you to double check this and see if you are running the CPU at slightly higher clock?

    By the way, is this on the LCDK EVM or your own custom board having the TMS320C6748  chip?

    Thanks

  • Just to make sure I understand your question, you have the ISR fired for every pulse which is @ 1 second rate. You are noticing the ISR spacing as 1,000,027 micro seconds.. and you are chasing the reason for additional 27 micro seconds right?

    Yes that is exactly the case.

    I am wondering, why are you expecting your clock source be a perfect clock? They would have jitter and if I read the above right, you are chasing the reason for 300,008,500 ticks. About 8500 ticks . Note that the TSC ticks for every CPU cycle.

    It makes me think you are running your CPU at 300,008,500Hz. Is it possible for you to double check this and see if you are running the CPU at slightly higher clock?

    I dont expect the clock source to work perfectly. But constantly working more than expected creates a problem. Also I think I have set the PLL settings correctly. I did tests not only with 300 Mhz clock source but also with with dirrefent frequencies (1 Mhz, 50 Mhz, 100 Mhz etc.) But all the time I got more tick count than expected from TSC.

    By the way, is this on the LCDK EVM or your own custom board having the TMS320C6748  chip?

    I have my own custom board.

  • Hi Yusuf,

    Thanks for the details and confirmation. 

    Can you please provide more details on how are you capturing the tick counts and measuring the 1second window? 

    By the way, is it possible for you to read the TSC register and drive a GPIO pin (output) high and after some time read the TSC and drive that pin to low and measure the time and TSC cycles?

    Basically, can you please rule out if you are be running the CPU at a slightly higher clock rate?  I have not heard anytime TSCL going out of sync with CPU cycles.

    Thanks

  • Hi Yusuf,

    I did the above experiment myself and noticed no issues on the TSC values. 

    The experiment that I did is below:

    1. set up a periodic timer interrupt and capture the TSCL, each time the ISR fires in the timer ISR

    2. Toggle a GPIO pin in the Timer ISR each time

    3. Read the TSCL value into an arrary

    4. Compute the difference between each read

    Observation:

    I see the timer getting fired for every 80ms and the TSCL delta shows the values around 300Mhz as below: (note the jitter around it).

    Please note that there is minor software jitters as well contributing to this. (handling interrupt service routine etc)

    TSCL Ticks Freq in Mhz
    Min 23999742.00 299.996775
    Max 24000204.00 300.00255
    Avg 24000197.70 300.002471231156
    Standard Deviation 32.63 0.000407882703522

    Please click the below to get the picture pop up.

  • Can you please provide more details on how are you capturing the tick counts and measuring the 1second window? 

    Every time the ISR runs, I take the time information from the TSC registers and put it into an array. Then I calculate the intervals between the elements of this array. Actually, I can say that it works with the math "present - previous = interval ".

    By the way, is it possible for you to read the TSC register and drive a GPIO pin (output) high and after some time read the TSC and drive that pin to low and measure the time and TSC cycles?

    Actually, I've done an experiment close to the experiment you mentioned before. I toggled one gpio pin every time in the interrupt service routine. I compared the signals on my interrupt input pin and the gpio pin that I toggle with the oscilloscope. I could not see a difference (error condition) between these two signals. This means that the problem is reading the time data in TSC.

  • set up a periodic timer interrupt and capture the TSCL, each time the ISR fires in the timer ISR

    I think there was a wrong approach in your experiment. As I understand it, your interrupt source is an internal structure. You need to understand whether there are any errors in the structure and use an external time source. Otherwise, since your  time reference is internal, it is not possible to catch the error condition.

  • Hi Yusuf,

    My time measurement is not internal. Yes, I am using the timer (dmTimer - internal timer) to enter into the ISR and I read the TSC in the ISR. But, note that I am outputting the GPIO toggle signal from the ISR to external Logic Analyzer and I am measuring the absolute time difference externally (the time pin stays high Or the time pin stays low) to check the counted TSC ticks.

    I do not see an issue in my experiment, since I am measuring the actual time externally for the accumulated TSC cycles.

    Thanks

  • Hi Aravind,

    As I understand, my intervals that I calculate from TSC are in acceptable scope. Also in your experiment average frequency is 300.002471231156 so average tick count 300 002 471 in a second on  the processor. Would not the average tick count be expected to be closer to 300 000 000?

    Many thanks for your interest

  • Hi Yusuf,

    Yes, we should expect the values close to 300MHz. I do not understand why you think 300.0025MHz that we got via software measurement using TSC is not close to 300Mhz?

    Note that there are many factors here:

    1. accumulation window, you can increase to higher to minimize the error

    2. exact sampling on TSC values when the GPIO signal shows up in the external Logic analyzer etc

    3. Clock jitters and PLL M and D values -- I think in my case, I have a low jitter osc and perfect M and D values.. So, this may be less impacting towards that .002MHz variation

    Overall, I think there is no issue.  Please let me know if you can close this thread.

    Thanks

  • Hi Aravind,

    Thank you very much for all your answers and interest.