# How can I measure the time between 2 events using the icapture function on the Xbee S3 programmable?

**URL:** <https://forums.digi.com/t/how-can-i-measure-the-time-between-2-events-using-the-icapture-function-on-the-xbee-s3-programmable/14249>\
**Category:** XBee - DigiMesh\
**Tags:** interrupt, codewarrior, xbee-900hp\
**Created:** [January 26, 2015, 10:37pm UTC](https://forums.digi.com/t/how-can-i-measure-the-time-between-2-events-using-the-icapture-function-on-the-xbee-s3-programmable/14249 "2015-01-26T22:37:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonofre](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tonofre](https://forums.digi.com/u/tonofre)\
**Post date:** [January 26, 2015, 10:37pm UTC](https://forums.digi.com/t/how-can-i-measure-the-time-between-2-events-using-the-icapture-function-on-the-xbee-s3-programmable/14249/1 "2015-01-26T22:37:44Z")

</div>

Hello, I just want to get the time between to digital pulses. I read the help, but I couldn’t figure out it.

This is the code that Im working. Thanks

#include  
#include

unsigned int counter =0;

unsigned int number, captcount=0;

void main(void)  
{  
sys\_hw\_init();  
sys\_xbee\_init();  
sys\_app\_banner();

```
//Interruption Routine

icapture_config(icapture0, ICAPTURE_RISING, TRUE, 1000000); //icapture_config(xpin_t pin, uint8_t edge, bool_t enable, uint32_t max_u_secs)

/*icapture0 to trigger an interrupt on rising edges, expecting a maximum of 1 second between edges:
 * */

for (;;) {
		
	number = icapture_captcount_to_usec(icapture0, captcount);
			
	sys_watchdog_reset();
	sys_xbee_tick();
}

```

}
