Hello I am i need of a piece of code that lets me invert a PWM signal of two PWM pins on the due. Example D1 will be 101010 and D2 will be 010101. Is it possible?

Im pretty limited in my options because, doing it externally is not an option because there will be a time where a change in mode is needed and both pins will be sending signal independently. Manually pulling the pins High and Low is also not an option for me because this will make the code blocking other codes.

  • inverted 75% is same as noninverted 25%
    – jsotola
    Jan 24, 2020 at 15:27
  • @jsotola i am having trouble visualizing that, although they would be opposing but the frequency would not match, the 25% would miss one cycle of the 75% . Am i missing something?
    – Jack
    Jan 24, 2020 at 15:42
  • take a piece of paper and a pencil ... dreaw 10 cycles of 25% PWM waveform ... rotate the paper upside down ... maybe I'm missing something
    – jsotola
    Jan 24, 2020 at 15:55
  • Image. The above signal in the image is 75% and the one at the bottom is 25%. the 25% is missing one cycle of the 75%
    – Jack
    Jan 24, 2020 at 16:03
  • 1
    you could use an xor gate to invert the PWM signal. this allows you to easily un-invert the signal with another GPIO pin feeding the gate's other input.
    – dandavis
    Jan 24, 2020 at 19:39

1 Answer 1


Not using the Arduino API, no. But you can by direct manipulation of the SAM3X8E registers.

You should study section 38 of the datasheet, where it mentions in the list of facilities:

  • Independent Complementary Outputs with 12-bit Dead-Time Generator (Also Called Dead-Band or Non-Overlapping Time) for Each Channel
  • Register manipulation is way over me, hopefully there is some examples.
    – Jack
    Jan 24, 2020 at 15:04
  • @Jack There probably are, but probably not around here. The Atmel forums might be good though.
    – Majenko
    Jan 24, 2020 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.