Hello,
i tried the examples with the analogWriteResolution(12).
The values can be send up to 4095, that's ok.
But the PWM duty cycle changes all 16 values.
That is a very bad resolution.
I checked it with another Due, but it's the same.
I use IDE 1.8.7
Who can help?
Can you post the code you used.
All 16 values of what are changed?
All 16 values of the A value (0-4095)
const int analogOutPin = 10;
int A =0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(57600);
analogWriteResolution(12);
pinMode(analogOutPin, OUTPUT);
}
void loop() {
A++;
analogWrite(analogOutPin, A);
if (A>=4095) {A=0;}
Serial.println(A);
delay(50);
}
You won't be able to get the maximum resolution with analogWrite() function.
Yu can output a PWM waveform either from the PWM peripheral or the Timer Counter. Search in the DUE sub forum for example sketches.
The Due has the same resolution like the Mega?
4096 / 16 = 255
For what is the analogWriteResolution(12) if it's always the same?
The resolution depends on the frequency you need. The highest frequency with the maximum resolution (16 bit) is obtained with a frequency of 84 MHz/ 65535 ~ 1282 Hz because de duty cycle can vary between 0 (0%) and 65535 (100%).
I give up and prepared a solution with my old MEGA. That program is working with a resolution of 1024 (with changing of the resolution)