CTC Timer Interrupt time millis(), File.write hang on

I have two Compare Interrupts on my Yun.
Everything works fine.
But when i look at the balance that when the interrupts run the code i feel confused.
Maybe somebody can help me.
Timer 3, 16 Bit, Prescaler 64 Interrupt run every 257ms, OCR3A = 64249
When i compare the mills() the timer is running, most ist 257ms.
but sometimes after 10, 20, 5, 12 … … … cycles sometimes the timer run after 256ms or also 258ms.
is the a feature or something else for making the timer exactly similar like embedded systems?

i write these Data into DB.
I write 4100 Lines in Database and 252 Times the Time is wrong.
Diff -1: 128 Times
Diff +1:122 Times
Diff +2: 2 Times
Timer init is:

TCCR3A = 0;
TCCR3B = (1 << WGM32) | (1 << CS31) | (1 << CS30);
TCCR3C = 0;
TCNT3 = 0;
OCR3A = 64249;
TIMSK3 = (1 << OCIE3A);
Who know how i can resolve this Problem?

The millis() timer on the Arduino isn't 100% accurate. it fluctuates +/- 1 ms (?) at any time, but maintains accuracy over time. So any millis time measurment could be up to 1 mSec out and rarely spot on to the microsecond.

If you can do your comparisons using elapsed microseconds(), which is 100% accurate all of the time. (subject to the crustal or resonator accuracy)

The millis() accuracy is related to the way it is implemented. A search will provide the details.

This probably expalins what you observed!

Hello, thank you for reply.

I use now micros()/1000 and it works fine, But I have a second Problem. I use the Bridge to write from the loop every 10 times the interrupt run i set a flag and write into a file from loop (File_Append) Timer 1 do this every 37ms and Timer 3 every 257ms It works fine on Linino side I have a cronjob that catch the file every minute and load the data into MySql. But after a few minutes the Atmega32u4 get busy for 2,3,4...8 minutes and then continue working, also continue work when i reset the atmega32u4. It is like the Bridge hanging on or get busy. It is necessary if i use File.write or Process.runShellCommand to comunicate with the Linino after many loops the Action corrupt. I write before open file and after closing file Serial.print(millis()) and it hang before the file is closing. something wrong or maybe is there a better,faster way to write into linino?


.....unfortunately, I cant be of further help with your other problem(s), but if you figure out a solution do post it.