The best approach to measure a time interval

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi,

   

I am new to PSoC programming and would like to have suggestions for the best approach to the measurement of time intervals. In pseudocode what I intend to do is the following:

   

start = now();
interactWithI2CPeripherals();
interval = now() - start;

   

The time to process the information in the I2C peripherals isn't known at first and I intend to have the time interval measured with a resolution of 1ms.

   

My first guess is to use a counter with a period of 1KHz and start the counting prior to the I2C interaction and read the counter value when finishing the I2C interface. Is this a good approach or is there a better solution?

   

Thanx,

   

Angelo

0 Likes
2 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

If you are trying to do this in your code base then 1 Khz counter would

   

suffice, using capture or just polled. Counter in bits X 1 mS should be

   

> largest I2C communication time, or account for counter rollover in

   

your code.

   

 

   

If your need is to establish the time for design purposes, do a trace when you

   

are debugging.

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

A useful ap note -

   

 

   

http://www.cypress.com/?docID=33518

   

 

   

Regards, Dana.

0 Likes