okay so this is the sketch
what it does is , it writes value in t1 whenever interrupt is generated and then stores the previous value in t2. "X" stores the difference value i.e x=t1-t2
By this i can find the time difference between two interrupts.
I have generated the interrupt by using delay function and digitalWrite (as you can see in the sketch) and connected the output to pin2 (int pin of arduino).
by using this i get a resolution of 2^23 bit in arduino due . As arduino due is a 32 BIT uc i could use its resolution to count the same. If i could use the internal timers of arduino due that would help me a lot.
Help is highly appreciated.
volatile unsigned long t1;
volatile unsigned long t2;
volatile unsigned long x;
int flashpin = 10;
void isr()
{
t1=micros();
}
void setup()
{
pinMode(flashpin,HIGH);
}
void loop()
{
attachInterrupt(0,isr,RISING);
flash();
x=t1-t2;
t2=t1;
}
void flash()
{
digitalWrite(flashpin,HIGH);
delay(1000);
digitalWrite(flashpin,LOW);
delay(1000);
}