analogRead problem (ARDUINO DUE)

I have a problem.
I was trying to output a voltage that goes from 0 to 3.3 on “digital PMW” and it works! (I think it’s correct use digital PMW for an analogWrite; if it’s not correct me).
The led is in series with a resistance.
When I use my A0 “analog in” for measure the voltage the return of “analogRead” is always 1 or 0. If I put my "A02 everywhere in the circuit the result is the same, but when I put my “A0” on the 3.3 power the result is 1023.

int sonda = A0; //ANALOG IN
int led = 2; //DIGITAL PWM

void setup() {

void loop() {
  for(int i=0;i<255;i++){
    analogWrite(led,i); // changing voltage from 0 to 3.3 (it works)

Sorry for bad english.

Despite the function name "analogWrite", you only get a true analog output on pins DAC0 and DAC1 on your Due. When you use analogWrite on pin 2, you are getting a digital PWM signal. Please read this tutorial to learn about PWM:

You won't get any useful information from reading a PWM signal using analogRead() (well, OK, you will when the PWM duty cycle is 0% or 100%, but not at any value between).

It is possible to convert a PWM signal into an analog signal using a simple RC smoothing filter.

You can set analogReadResolution(bits) to 10 (0 to 1023) or 12 (0 to 4095) bits for the DUE. You can set analogWriteResolution(bits) to 8 or 12 bits.