hello every one
i want to compare two outputs from interrupt but when i save the last one in a parameter " f " the current one "Tx " stop changing and "m" won't increase.
#include "tc_lib.h"
using namespace arduino_due;
#define CAPTURE_TIME_WINDOW 2500000 // usecs
#define ANALOG_PIN 7
#define ANALOG_VALUE 127 // values in the interval [0,255]
capture_tc0_declaration();
auto& capture_pin2=capture_tc0;
volatile float Tx = 0 ;
volatile float f = 0 ;
volatile float t = 0 ;
volatile int m = 0 ;
void setup() {
Serial.begin(19200);
Serial3.begin(38400);
capture_pin2.config(CAPTURE_TIME_WINDOW);
attachInterrupt(digitalPinToInterrupt(2), measure , LOW );
}
void measure (){
uint32_t status,duty,period;
status=capture_pin2.get_duty_and_period(duty,period);
t = (static_cast<double>(duty)/static_cast<double>(capture_pin2.ticks_per_usec()) );
if ( (t > 1400) && (t < 1600))
{ Tx = t ;}
}
void loop() {
if (Tx - f > 1)
{
f = Tx;
m++;
}
delay(20);
Serial3.println(m);
}
this is the interrupt output and i want to count the number of spikes
any little help would be greatly appreciated in advance.