PMW vs PIN

Is there any reason why a pulse train generated with PWM makes perfect square pulses and a pulse train generated with digitalWrite HIGH and LOW genrates pulses with tails resulting in pulses that never get LOW to 0 Volt at higher frequencies?

patrickrombaut:
Is there any reason why a pulse train generated with PWM makes perfect square pulses and a pulse train generated with digitalWrite HIGH and LOW genrates pulses with tails resulting in pulses that never get LOW to 0 Volt at higher frequencies?

Is there any reason why you hijacked this old thread, instead of starting your own?

Is there any reason why a pulse train generated with PWM makes perfect square pulses

Only for a 50% duty cycle.

a pulse train generated with digitalWrite HIGH and LOW genrates pulses with tails resulting in pulses that never get LOW to 0 Volt at higher frequencies?

Did you remember to set the pin to be an OUTPUT?

@patrickrombaut

TOPIC SPLIT
PLEASE DO NOT HIJACK / NECRO POST !

Could you take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

You could begin by posting your code, after you read the links...

Sorry, didn't mean to offend anyone, this was my first question ever on any forum.
I will take some time to learn how to use the forum ...
BTW, setting the pins to OUTPUT made the difference, perfect pulses now, thank you.

patrickrombaut:
BTW, setting the pins to OUTPUT made the difference, perfect pulses now, thank you.

Do you understand why?

Not yet, still searching the Troubleshooting...

It's because if the pin isn't an output, it's a high impedance input, and the digitalWrite HIGH is enabling the internal pullup and the digitalWrite LOW is disabling the internal pullup.

When not controlled by software, digital I/O pins are INPUT state since DDxn is 0, allowing the capacitor in the output circuit to discharge slowly (visible as a tail after the pulse). PinMode OUTPUT disables the pull-up resistor so the capacitor is not able to discharge slowly (no tail anymore).
Am I thinking in the right direction?