now i just put
Serial.println("------------------------");
Serial.println(Tx);
Serial.println(f);
Serial.println(m);
and noticed that the output is like this :
1476.62
1476.62
1
1476.62
1476.62
1
1476.62
1476.62
1
1476.62
1476.62
1
1476.62
1476.62
1
but when i compile below code
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);
//-------------------------------------------------------------------
Tx keep changing.
do you have any idea why it doesn't change when i compile the main code that's mentioned at the begining.