Duemilanove PWM outputs are different? Oscope image attached

Looks like channel two is running twice the Hz but 1/2 the duty cycle

Channel 1 is digital pin 3 Channel 2 is digital pin 6

Link to Imgur image: http://imgur.com/kxuqDuk

void setup()
{
  Serial.begin(9600);
  
  pinMode(3, OUTPUT);
  pinMode(6, OUTPUT);
}

void loop()
{
  int x = analogRead(1);
  x = map(x, 0, 1023, 0, 254);
  analogWrite(3, x);
  analogWrite(6, x);
  Serial.println(x);
  delay(5);
}

Okay I found it in here: http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM

Pin 3 = Fast PWM
Pin 6 = Phase-Correct PWM

"The Arduino has a system clock of 16MHz and the timer clock frequency will be the system clock frequency divided by the prescale factor. Note that Timer 2 has a different set of prescale values from the other timers. "

int x = analogRead(1);
  x = map(x, 0, 1023, 0, 254);
  analogWrite(3, x);
  analogWrite(6, x);
  Serial.println(x);
  delay(5);

Why not

int x = analogRead(1) / 4;
  analogWrite(3, x);
  analogWrite(6, x);
  Serial.println(x);
  delay(5);

?

AWOL: int x = analogRead(1);   x = map(x, 0, 1023, 0, 254);   analogWrite(3, x);   analogWrite(6, x);   Serial.println(x);   delay(5);

Why not

int x = analogRead(1) / 4;
  analogWrite(3, x);
  analogWrite(6, x);
  Serial.println(x);
  delay(5);

?

AnalogRead gives values from 0-1023 but AnalogWrite will only give values from 0-253 so you need to map the values across.

but AnalogWrite will only give values from 0-253

If you say so.

sniffing1987: AnalogRead gives values from 0-1023 but AnalogWrite will only give values from 0-253 so you need to map the values across.

analogWrite() can take values from 0 to 255 (as per the size of an unsigned char). What is 1023/4 ? (hint, truncate the decimal, that's how computers work). You can save time and RAM by simply doing:

byte x = (analogRead(1) >> 2); //Note the bit shifts, rather than the division. I have a sneaking suspicion though that GCC optimises out the division anyway

AWOL:

but AnalogWrite will only give values from 0-253

If you say so.

oops, slip of the fingers, meant to say 255!

Steelmesh: Looks like channel two is running twice the Hz but 1/2 the duty cycle

Same duty (50/50), but different freqs (periods).

Did you alter, from their stock config., a timer register?