title: PWM Issue with arduino due (cortex-m3)
body: <p>I am using PWM on an arduino due board which uses SAM3X8E(cortex-m3) microcontroller. When I use PWM enable and disable on this board, the waveform goes analog on disabling the channel, instead of staying at 0 or 1. Please see the attached waveform. I tried the code by directly writing to registers also, but it was the same. I also tried a 4.7k pulldown resistor at pwm output, but got the same results. Please tell me how to fix it in software. </p>
  
  <p>If a hardware solution is also possible with some external components, that is also ok. Scope images are attached. The blue scope output is for line 34 (PC02) and yellow for line 35 (PC03). </p>
  
  <pre><code>// include all arduino libraries here.. these are only accepted from ino files.
  #include &lt;Arduino.h&gt;
  #include &lt;SD.h&gt;
  #include &lt;SPI.h&gt;
  #include &lt;Ethernet.h&gt;
  
  void setup() {
    // put your setup code here, to run once:
    pmc_enable_periph_clk (PWM_INTERFACE_ID) ;  // turn on clocking to PWM unit
  
    PWMC_ConfigureChannel (PWM, 0, 1, 0, PWM_CMR_CPOL) ; // PWM channel 0, clock = MCLK/2 = 42MHz
    PWMC_SetPeriod (PWM, 0, 700) ;  // period = 700 pwm clocks (60kHz)
    PWMC_SetDutyCycle (PWM, 0, 80*700/100) ;  // duty set to 80%
    PWMC_EnableChannel (PWM, 0) ;   // enable
  
    // Configure pin 34 (PC2) to be driven by peripheral B (PWM channel 0 L)
    // enable pin PC02 and PC03, they are complimentary
    PIOC-&gt;PIO_PDR = 0xC ;  // disable PIO control
    PIOC-&gt;PIO_IDR = 0xC ;   // disable PIO interrupts
    PIOC-&gt;PIO_ABSR |= 0xC ;  // switch to B peripheral
  
  }
  
  void loop() {
    // put your main code here, to run repeatedly:
  
  
  // From these settings, I got these numbers from the scope - 13.3us on time and 3.32us off time
  //
  
    PWMC_EnableChannel (PWM, 0) ;   // enable
    delayMicroseconds(100);
    PWMC_DisableChannel (PWM, 0) ;   // enable
    delayMicroseconds(100);
  }
  </code></pre>
  
  <p>Ans here's the scope images:</p>
  
  <p><img src="https://i.stack.imgur.com/cVfzl.jpg" alt="scope image"></p>