Go Down

Topic: Change resolution of PWM in Due (Read 82 times) previous topic - next topic


I have been going through the wiring_analog.c file and have found that values written to PWM irrespective of user defined resolution gets mapped to 8 bits. Please see the lines below:

   if ((attr & PIN_ATTR_PWM) == PIN_ATTR_PWM) {
         ulValue = mapResolution(ulValue, _writeResolution, PWM_RESOLUTION);
      if ((attr & PIN_ATTR_TIMER) == PIN_ATTR_TIMER) {
         // Map value to Timer ranges 0..255 => 0..TC
      ulValue = mapResolution(ulValue, _writeResolution, TC_RESOLUTION);

where PWM_RESOLUTION/ TC_RESOLUTION is 8 as defined in $IDEINSTALLPATH\hardware\arduino\sam\variants\arduino_due_x\variant.h

As per I gather we can have 12 bit PWM generated on Due. Then why mapping it to 8 bits? Should it not be the higher end that the hardware supports i.e. 12 bits?

Go Up