errors with micros() function on Teensy 3.1

Status
Not open for further replies.

Borja

Active member
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?

Archivo 11-4-17 22 42 15.jpg
Archivo 11-4-17 22 45 56.jpg
 
thanks for posting a sketch
everyone has a blindfold on and can only guess why it's not working, or WHY WE SEE NO CODE RELATING TO SERIAL OUTPUT either, makes us less likely to help you.. you should be using code brackets as well in your post, look at what you posted, WE CAN NOT TELL YOU WHY the MAC is getting those values, you clearly have not given the info we need to answer that.
Theres a RED hyperlink on top of every forum thread, READ IT.
 
Last edited:
@tonton81 - yes, the forum rule is being disregarded here, but you could also tone this down a bit. Everyone deserves respect. Even people not following the rules deserve suggestions spoken respectfully.
 
Status
Not open for further replies.
Back
Top