Arduino Due 12-bit PWM?

Hello,

I have read on the website that the 12 PWM output pins on the Due are 8-bit. However, it also says that the output of the PWM pins can be changed with the analogWriteResolution() command.

Is it therefore possible to use the 12 PWM outputs with 12-bit resolution? Or are the only 12-bit resolution outputs on the board the two DACs?

Thanks!

http://arduino.cc/en/Reference/AnalogWriteResolution

I did read that page, but it is still unclear to me.

"The Due has the following hardare capabilities:

12 pins with 8-bit PWM (as the other AVR based boards)
2 pins with 12-bit DAC (Digital-to-Analog Converter)

By setting the write resolution to 12, you can use analogWrite() with values between 0 and 4095 to exploit the full DAC resolution or to set the PWM signal without rolling over. "

Does that mean the PWM outputs can be used to get 12-bit resolution, or just that it evenly distributes 8-bit resolution over 12 bits?

Yes - it is just saying that if you specify 12 bit resolution on a PWM channel, you'll only get 256 levels, spaced 16 counts apart.

Great, thanks for clarifying that.

AWOL:
Yes - it is just saying that if you specify 12 bit resolution on a PWM channel, you'll only get 256 levels, spaced 16 counts apart.

Actually, it seems to be not true. The same link to docs now says:

The Due has the following hardware capabilities:

  • 12 pins which default to 8-bit PWM, like the AVR-based boards. These can be changed to 12-bit resolution.
  • 2 pins with 12-bit DAC (Digital-to-Analog Converter)

so the 8bit is just the default mode, but it actually is 12bit PWM.

Page 1048, Sam3x datasheet:

PWM_CPRD (to set the frequency) is a 16-bit register and PWM_CDTY (to set the duty cycle) is a 16-bit register, therefore the maximum resolution of the PWM controller is 16-bit. Note that TC_RC (to set the frequency) is a 32-bit register, idem for TC_RA (to set the duty cycle).