the closing bracket is missed here but in this code Tx will change correctely :
#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 ;
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() {
delay(20);
Serial.println(Tx);
}
but at the moment i put " f " in it to save the value of " Tx " , it stops changing
the code is here for comparing " f " and " Tx " :
#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 ;
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 > 5)
{
f = Tx;
m++;
}
delay(20);
Serial.println(m);
}