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.

TMS570LC4357: Measuring time beetween a discrete edge and a software event

Part Number: TMS570LC4357

Hello, 

I am very new in the develpment on TI ARM CPU. 

I need to know the time passed between a software event (like begin of a calculation) and a rising edge on a discrete input. 

I have think about 2 ways:

- Raising an interupt on the rising edge and get the time. But the interuption will interact with the computation.

- Using the nhet. But I don't know how to configure nhet and how to pick up the tilme.

May be it will be some other better ways to do it and I will be very happy to have your advice. 

Alain 

PS: soory for my poor english, it is not my natural laguage. 

  • Hello Alain,

    The easiest way to do this is to use the RTI counter. At the start of the calculation, read the counter and store the count (T1). At the receipt of the discrete input rising edge, read the value again (T2) and store. If T2 is smaller than T1, then you can determine that a roll over occurred so it can be accommodated in the calculation. If not then it is simply T2-T1 = RTI Counts and RTI Counts can be converted to raw time based on the chosen clock source cycle time for RTI. This will be subject to some error due to the latencies of reading and writing the RTI register content and also due to processing the incoming signal. You should be able to estimate this latency based on the cycles it takes to execute the instructions for each process and latency for access to peripheral modules (~24 HCLK cycles).

    The other key is how you will capture the incoming signal. You could bring it into an interrupt capably pin (ex. GPIO with interrupt) and then read the RTI in the interrupt service routing or you could simply poll the GPIO register looking for a change to the pin.

    The method chosen is really dependent on the accuracy or the needed measurement. As you mentioned, you could also use the NHET to capture the input signal and an associated count related to a cycle counter In the N2HET. Again, the accuracy of such a measurement would have some latency involved given the time needed to start the counter via SW and the HTU. The precision of the measurement would also be limited to the LR loop and HR Loop capabilities of the NHET.

    Note that any m
  • Hello Chuck, 

    Thnaks for your very accurate answer. 

    The goal is to synchronize 6 computers in order to make calculation in the same time (same time means max gap < 10µs).

    So, we need an accuracy of 5µs.  

    If I assume that HCLK is 160MHz (6.25ns), I have around 800 HCLK cycles to feet into 5µs. I think it will be enougth for: reading and writing RTI,  handle interrupt and made some basic time calculation.

    Am I rigth or I have miised something.  

  • Hello Alain,

    I would tend to believe the same as your assumption. This could then also be improved by providing an input into the device to gate the beginning of the calculation as well.