arduino 2009 precision as wave gen ????

hi!! I'm attempting to do a ck generator with arduino 2009 to test some data low rate equipments (typcal 48/64 kbps)..

Using a simple code to generate a ck 64, I always see a poor stability: the wave seems "jump" about 1/2 times for second..

I try do use digital write or direct port access (more faster..) but the result is always the same.. the wave has some irregularity every 1/2 time for seconds..

Do you meet these problems?

I not used any interrupts or other code except port define and loop cycle with digitalwrite high or low, with simple for cycles to define the time...

It is arduino 2009 "low stable" ??? Probably I make some mistakes.. :-[

I not used any interrupts

You don't but the arduino does to maintain things like the serial port and the millis() counter.

In my code I have nothing except these row code
(Only a square ck generator, with dummy loop to trim the ck frequency)

#define CK 2 // CK port on hw arduino 2009
int i,dummy = 0;

void setup() {

pinMode(CK, OUTPUT); // CK OUT 64 khz


void loop() {

PORTD = PORTD | B00000100 ; // ck go HIGH

for (i=0;i<25;i++) { // dummy cycle, 7 uSeconds

PORTD = PORTD & B11111011 ; // ck go LOW

for (i=0;i<25;i++) { // dummy cycle, 7 uSeconds


This code causes a irregular 64 kHz generation!!!
I cannot obtain a stable wave… it seems “click” every 1/2 time for a second…

Are other processes anyway active when I download this code?
If yes, it is possible do disable them, in order to have only the LOOP active ???


Are other processes anyway active when I download this code?

Yes I said there are interrupts that keep the whole system working.

I suppose it would be possible to disable them but I haven't see any one do it. However for this sort of tight code you really need to be programming something in assembler.

thank you! I'll use another target with a avr64 to do these sync operations.. :-)