[En-Nut-Discussion] Ethernut 3 (Arm), servo timer in us range weird behaviour

Marcus-O Jawo mojawo at googlemail.com
Thu Aug 7 12:42:55 CEST 2008


Hi all.

Im using an Ethernut 3, AT91R40008 to control a servo using timer  
interrups to count 10.000 ticks per second thereby allowing step sizes  
of 0.1 ms. I connected the Ethernut expansion port to an oscilloscope,  
when I set StepSize to 10  (1 ms) or 20 (2 ms) the output were nice  
rectangle waves of width 1 or 2 ms, but if i set it to anything in  
between 10 and 20 lets say 15 I would see an equal amount of 1 ms and  
2 ms width waves. If I set StepSize to 18 I would receive less 1 ms  
rectangles than 2 ms and so on, but never any rectangles with the  
expected width.

Here I set the counter 73.727.263 Hz / 2 = 36.863.631 Hz
outr(TC1_CMR, TC_CLKS_MCK2 | TC_CPCTRG | TC_WAVE | TC_EEVT_XC0);

Compare value = 3.689 therefore ten ticks every millisecond.
outr(TC1_RC, 0xE69);

The interrupt looks like this:

int OnTicks = 150; 	// 15 ms
in StepSize = 15		// 1.5 ms

void ApiTimerIntr(void *arg)
{
	if (counter == OnTicks)
	{
		outr(PIO_CODR,_BV(8));
	}
	else if(counter == OnTicks + StepSize)
	{
		outr(PIO_SODR,_BV(8));
		counter = 0;
	}
	counter++;
}

I would be very thankful for any suggestions on this behaviour.

Regards,

Marcus-O Jawo.




More information about the En-Nut-Discussion mailing list