SAM7S PWM Servo control

I am having difficulty connecting a servo to my SAM7-P256 from Olimex.

Here is my code:

	pPWMC->PWMC_DIS = AT91C_PWMC_CHID0 | AT91C_PWMC_CHID1 | AT91C_PWMC_CHID2 | AT91C_PWMC_CHID3;
	pPWMC->PWMC_MR = ((10 << 8 ) | 0x01 );  // MCK selection or'ed with Divider
		pwm->PWMC_CMR=
		//	AT91C_PWMC_CPRE_MCK |		// Divider Clock ?
			AT91C_PWMC_CPRE_MCKA |		// Divider Clock A
		//	AT91C_PWMC_CPRE_MCKB |		// Divider Clock B
			AT91C_PWMC_CPD |			// Channel Update Period
		//	AT91C_PWMC_CPOL |			// Channel Polarity Invert
		//	AT91C_PWMC_CALG |			// Channel Alignment Center
			0x0;
		// Set the Period register (sample size bit fied )
		pwm->PWMC_CPRDR=938;
		// Set the duty cycle register (output value)
		pwm->PWMC_CDTYR=70;
		// Initialise the Update register write only
		pwm->PWMC_CUPDR=0;
	AT91C_BASE_PWMC->PWMC_ENA=1;
	...pause for a while...
	AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CUPDR=100;
	...pause for a while...
	AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CUPDR=70;

I cant seem to figure out the calculation for period (I want 20ms) and duty cycle (I want 1.5ms). The board is running at ~48MHz from what all the examples I have looked at seem to say. Does anyone have an easy way to figure out what dividers/prescalers I need and then what period and duty cycle to set?

The servo reacts differently when I try different values (although it always ends up pegging to the right) so I think I have everything initialized correctly.

This is my first foray into embedded/microcontroller programming, but I do have plenty of experience in C elsewhere.

Thanks,

Joe

JoeGTN1:
I am having difficulty connecting a servo to my SAM7-P256 from Olimex…

So, nearly 24 hours later I figured out that I’m a much better programmer than electrical engineer. If I hold the PWM signal line and the servo signal line it miraculously works. Well, not so miraculous, it turns out that there needs to be a capacitor in line. I put one in, it still doesn’t work, I put a cap and a resistor in, it works.

Could the EEs around let me know why this is, and how to find out what size/rating capacitor and size/rating resistor I should have in the circuit. I assume that my body and/or some random cap and resistor that I pulled out of some random component that I have lying around probably isn’t the best solution.