Problem with displaying the digital signal waveform

Hello everyone,
I have a problem with displaying the digital signal shape as shown in the adjacent figure.

If I use a lower sampling frequency, everything is OK.
Can someone help me?
Thank you in advance,
Teo

You have noise on the signal. The sampling rate for the analog signal isn’t high enough to show the noise, partly because there is a low pass filter on the analog input.

You may find that improving grounding helps reduce noise and improves the result for digital signals. Place one of the ground wires for the analyzer on a ground point close to the signal you are measuring.

Hi,
The distance between the GND and the microcontroller output is 4 mm.
Thank you for the answer !
Teo

You can also turn on glitch filtering:

… or, get a higher bandwidth scope and/or fix your signal noise issue.

Thank you for the answer !
Teo