Hi, the delayMicroseconds(); function ho much time have implicit in himself to execute at 8Mhz?
Is possible to know the time spended for a function or operand etc?
Yes, that can probably be done, but why do you think that would be useful to you?
To adjust the accuracy of the gap based in the error that have the crystal.
It may be better not to use delay() in the first place. How long is the "delay" that you are trying to implement ?
0.666 period microsec seem a joke but is not.
Do you mean that you are trying to use delay() to achieve a period of 0.666 microseconds ?
If is possible yes, but dunno. just know delayMicroseconds(); function and is too big.
The execution time of delay() will be affected by the inaccuracy of the crystal, so knowing it won't make your timing accurate.
Your question is often called an "X-Y Problem". Please tell the forum what your project is about, what you are trying to achieve.
Do you realise that delay() uses milliseconds ?
Is a counter timer based in internal timer1 16 bits at 8Mhz, that have some gap. nothing special, but i want to set it as similar as possible to an atomic clock.
Yes, i make wrong the title, sorry.
But sure than delay(); and delayMicroseconds(); try the same time to execute himself.
That is the how of your project. I asked what is your project about.
If you will not tell the forum, then you risk wasting the forum's time and your own time trying to solve problem X when you need to be solving problem Y.
You can generate as low as 62.5 ns (1/16000000) time delay using Timer/Counter1.
Yes and based in prescaling 256 to have integer numbers, with 8 Mhz is the same because is the half of 16Mhz, so i can adjust to 31250 *2, but have some gap even using integers because the crystal is not 8 MHz, it is 8 MHz or something around and any function spend his own time to execute.
I don't remember now how much difference it had when i measured it with the oscilloscope.
And "Is a counter timer based in internal timer1 16 bits at 8Mhz that have some gap" dont answer the question?
take a scope an measure.
then you know exactly how long YOUR controller will take at exactly that temperature you have measured at.
I don't think you can accurately measure the frequency of a quartz crystal with an oscilloscope. Normally, the measuring accuracy of the oscilloscope will not be better than the frequency accuracy of the quartz crystal - if at all.
To exactly measure the oscillation frequency of a quartz crystal, you need a very accurate ( and expensive ) frequency meter.
Or is there only a cheap resonator ( or even the internal oscillator ) on your board?
Is a counter, not a thermometer, i measured all that i can and i have a gap of, 0.666 period microseconds but unknow how reduce or eliminate, im thinking, introducing some neutral commands to make some delay, like seg=seg; in some parts of the rutine or betwhen the change of each second but is more effective if i know how much try each function or operand to reduce the 0.666 microseconds.
I see that you have changed the topic title so that it now refers to delayMicroseconds() rather than delay()
Of course, a function that counts in microseconds cannot be used to provide a delay of less than one microsecond, so a different technique will be required