user7807: I am using this code to make 10 bit PWM on port number 9, it seems like everything printed is 0,1022 rather than printing 0, 512, 1023. Is there a problem in my code ?
I wired pin9 to A3 to get the output and print it.
  void setup() {
  Serial.begin(9600);
  pinMode(A3,INPUT);
  // Set PB1/2 as outputs.
  DDRB |= (1 << DDB1) | (1 << DDB2);

  TCCR1A =
      (1 << COM1A1) | (1 << COM1B1) |
      // Fast PWM mode.
      (1 << WGM11);
  TCCR1B =
      // Fast PWM mode.
      (1 << WGM12) | (1 << WGM13) |
      // No clock prescaling (fastest possible
      // freq).
      (1 << CS10);
  OCR1A = 0;
  // Set the counter value that corresponds to
  // full duty cycle. For 15-bit PWM use
  // 0x7fff, etc. A lower value for ICR1 will
  // allow a faster PWM frequency.
  ICR1 = 0x03ff;
}

void loop() {
  // Use OCR1A and OCR1B to control the PWM
  // duty cycle. Duty cycle = OCR1A / ICR1.
  // OCR1A controls PWM on pin 9 (PORTB1).
  // OCR1B controls PWM on pin 10 (PORTB2).
  OCR1A = 0x0000;
  delay(500);
  Serial.println(analogRead(A3));
  OCR1A = 0x0200;
  delay(500);
  Serial.println(analogRead(A3));
  OCR1A = 0x03ff;
  delay(500);
  Serial.println(analogRead(A3));
}

The output looks like that:
  0 0 1022 1021 0 1022 1021 0 0 1021 0 1021 1021 0 0 1021 0 0 1022

no data between 0 and 1022 are presented.
thanks.

user28033: On your code, you using analogRead but declaring the pin (A3) as output. Change it to pinMode(A3,INPUT);
Aside from that, PWM is basically a digital output which changing (HIGH and LOW) at specified frequency. When the result you got is 

0 0 1022 1021 0 1022 1021 0 0 1021 0 1021 1021 0 0 1021 0 0 1022

There's nothing wrong. 0 --> LOW, and 1021++ --> HIGH
If you want "measure" something from the PWM, use pulseIn() instead, you can check the documentation here.    
If you want to measure the PWM value, I suggest you read:
Can I connect a PWM pin on one Arduino to an analog input on another? 

7807: <p>I am using this code to make 10 bit PWM on port number 9, it seems like everything printed is 0,1022 rather than printing 0, 512, 1023. Is there a problem in my code ?</p>

<p>I wired pin9 to A3 to get the output and print it.</p>

<pre><code>  void setup() {
  Serial.begin(9600);
  pinMode(A3,INPUT);
  // Set PB1/2 as outputs.
  DDRB |= (1 &lt;&lt; DDB1) | (1 &lt;&lt; DDB2);

  TCCR1A =
      (1 &lt;&lt; COM1A1) | (1 &lt;&lt; COM1B1) |
      // Fast PWM mode.
      (1 &lt;&lt; WGM11);
  TCCR1B =
      // Fast PWM mode.
      (1 &lt;&lt; WGM12) | (1 &lt;&lt; WGM13) |
      // No clock prescaling (fastest possible
      // freq).
      (1 &lt;&lt; CS10);
  OCR1A = 0;
  // Set the counter value that corresponds to
  // full duty cycle. For 15-bit PWM use
  // 0x7fff, etc. A lower value for ICR1 will
  // allow a faster PWM frequency.
  ICR1 = 0x03ff;
}

void loop() {
  // Use OCR1A and OCR1B to control the PWM
  // duty cycle. Duty cycle = OCR1A / ICR1.
  // OCR1A controls PWM on pin 9 (PORTB1).
  // OCR1B controls PWM on pin 10 (PORTB2).
  OCR1A = 0x0000;
  delay(500);
  Serial.println(analogRead(A3));
  OCR1A = 0x0200;
  delay(500);
  Serial.println(analogRead(A3));
  OCR1A = 0x03ff;
  delay(500);
  Serial.println(analogRead(A3));
}
</code></pre>

<p>The output looks like that:</p>

<pre><code>  0 0 1022 1021 0 1022 1021 0 0 1021 0 1021 1021 0 0 1021 0 0 1022
</code></pre>

<p>no data between 0 and 1022 are presented.</p>

<p>thanks.</p>
 28033: <p>On your code, you using <code>analogRead</code> but declaring the pin (A3) as output. Change it to <code>pinMode(A3,INPUT);</code></p>

<p>Aside from that, PWM is basically a digital output which changing (HIGH and LOW) at specified frequency. When the result you got is </p>

<blockquote>
  <p>0 0 1022 1021 0 1022 1021 0 0 1021 0 1021 1021 0 0 1021 0 0 1022</p>
</blockquote>

<p>There's nothing wrong. 0 --> LOW, and 1021++ --> HIGH<br>
If you want "measure" something from the PWM, use <code>pulseIn()</code> instead, you can check the documentation <a href="https://www.arduino.cc/en/Reference/PulseIn" rel="nofollow noreferrer">here</a>.    </p>

<p>If you want to measure the PWM value, I suggest you read:<br>
<a href="https://arduino.stackexchange.com/questions/10041/can-i-connect-a-pwm-pin-on-one-arduino-to-an-analog-input-on-another">Can I connect a PWM pin on one Arduino to an analog input on another?</a> </p>
