Hi,
I am using the micros function to count the duration of a program cycle.
I send via USB the value and I receive 19,897 on the Mac but on the TFT the value is very different... more than 100,000. I understand these values are the time in microseconds but the second value is a nonsense because the duration is around 20ms (50Hz).
At the beginning of the cycle I calculate the timer=micros(); and at the end I calculate the new value and send the values:
timer=micros()-timer;
Serial.println(timer);
if(contador==0){
tft.println("=======================");
tft.print("MICROS = ");
tft.print(timer);
tft.println(" us");
tft.println("-----------------------");
tft.print("FRECUENCIA = ");
tft.print((float)1e6/timer);
tft.println(" Hz");
Why do I see two different values? How can I fix it?
I am using the micros function to count the duration of a program cycle.
I send via USB the value and I receive 19,897 on the Mac but on the TFT the value is very different... more than 100,000. I understand these values are the time in microseconds but the second value is a nonsense because the duration is around 20ms (50Hz).
At the beginning of the cycle I calculate the timer=micros(); and at the end I calculate the new value and send the values:
timer=micros()-timer;
Serial.println(timer);
if(contador==0){
tft.println("=======================");
tft.print("MICROS = ");
tft.print(timer);
tft.println(" us");
tft.println("-----------------------");
tft.print("FRECUENCIA = ");
tft.print((float)1e6/timer);
tft.println(" Hz");
Why do I see two different values? How can I fix it?