Problem with Timer 3 Atmega1281

Hello,

I am using Atmega1281 with a 8Mhz frequency. I am trying to configure the Timer3 as CTC mode without prescaler:

TCCR3A= 0xC0;
OCR3A=0x00F0;
TCCR3A= 0x40;
TCCR3B= 0x09;

I do not understand why I get some cycles of 20 microseconds and others with 40 microseconds.

If I change the pulse frequency:
OCR3A=0x00A0;
Then I get cycles of 20 microseconds but every 3.2 milliseconds a get a strange cycle.

Do you know what is the problem?
Thank you very much.

How are you measuring the length of your cycles? Is it possible that your measuring equipment is not set up to measure periods this small?

--
Need a custom shield? Let us design and build one for you.

I am using an oscilloscope Handyscope HS3. I can see the cycle every 20 microseconds.

Meh...I would blame the scope. I've never trusted those PC-based models to provide quality results. See if you can get your hands on a real bench scope to confirm your observations, as I don't see any reason why you should be observing "hiccups" in your timer output.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

You were right, the oscilloscope was the problem.