in this code Tx changes :
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() {
delay(20) ;
Serial.println(Tx);
}
but in this code Tx doesn't change
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 > 5)
{
f = Tx;
m++;
}
delay(20) ;
Serial.println(m);