Hi VIO47. As exe and others have said it is possible that several factors are involved but I am betting that the limitation you are seeing is not your probing technique - rather the limitation is the capability to generate the "rectangular" waveform you were anticipating in the first place. And as tggzzz points out the underlying factor is rise time. (This is not to minimize the importance of probe technique including good probe grounding to minimize ringing. This video by W2AEW is definitely worth watching:
- but the larger issue you are facing is bandwidth and bandwidth’s relationship to rise time.)
I realize you are using a ST32F103 board with a PWM timer but if for example we were to look at the specs on a Siglent SDG2122X waveform generator that produces a 120 MHz maximum output frequency for sine waves we would see that the 2122X produces a maximum 25 MHz square wave, with a 9 ns rise time. If we were to look at an even more expensive Agilent 33522B waveform generator we would see that it has a 30 MHz maximum bandwidth sine wave and it produces a maximum 30 MHz square wave, with a 8.4 ns rise time. In general, when you look at the sales literature for waveform generators they consistently emphasize the maximum frequency or bandwidth as being that of the sine wave produced. Other waveforms such as square waves and pulses will sometimes/generally/often be produced at lower frequencies. Of course, each make and model of generator employs some techniques that will influence the ability of the generator to create the desired waveforms with integrity – but bandwidth is a fundamental consideration and rise time is related to bandwidth.
The following articles gives formulas showing the relationship between bandwidth (as expressed by frequency) and rise time.
https://www.edn.com/electronics-blogs/bogatin-s-rules-of-thumb/4424573/Rule-of-Thumb--1--The-bandwidth-of-a-signal-from-its-rise-time As mentioned, for various reasons the 0.35 "rule of thumb" is a rule of a thumb rather than an absolute. Nonetheless, using the rule of thumb I have attached a copy of a spreadsheet showing simple calculations for several frequencies - this provides a quick glance at the relationship between bandwidth and rise time. The spreadsheet gives the rise time (Tr) results in nanoseconds (ns) and picoseconds (ps).
At the top we see that a 20 MHz bandwidth will yield a rise time of about 17.5 ns. We see that 70 MHz (the clock speed I think on your STM32F103) can potentially yield a rise time of 5.0 ns. Further down we see a 200 MHz bandwidth will yield a rise time of 1.75 ns, and a 400 MHz bandwidth will yield a rise time of 0.875 ns or 875 ps.
To help describe what you might visualize along these lines, if you were to connect an Agilent 33522B generator (rated to produce a 30 MHz square wave with a 8.4 ns risetime) to a 400 MHz Tektronix 2467B oscilloscope and you set the Agilent to produce a square wave with a frequency of 5 MHz you would get something on the Tek scope that would look reasonably like a square wave. But if you turned the frequency dial on the Agilent generator upward by the time you reached 30 MHz on the generator you would think the 400 MHz scope was displaying something that looks much more like a sine wave than a square wave.
(Keep in mind that when we measure rise time we are generally looking at the time it takes a rising slope to go from 10% of it's peak amplitude to 90% of it's peak amplitude.)
To help further describe what things might look like at higher speeds we find that 10 GHz could yield a 35 ps rise time. So while a 200 MHz scope would seem pretty “snappy” (not a technical term) in it’s ability to produce a 1.75 ns rise time if we could see a rising slope at 1.75 ns next to a rising slope at 35 ps we would think the 35 ps waveform is headed almost “straight up” and the 1.75 ns waveform by comparison looks pretty “diagonal”. Regardless of our ability to put human adjectives on what we see with our eyes, our test equipment can give us measurable results and what we associate with square vs rounded or diagonal is best presented quantifiably as rise time – which is a function of bandwidth. And in the end our test equipment is kind of like the proverbial chain in which the weakest link (either the bandwidth of the waveform generator or the bandwidth oscilloscope) determines our ability to generate and measure rise time.
One other observation about your observation. When I first got into studying this stuff I thought a square wave would be an ideal waveform to help keep track of clock timing and to ensure the integrity of data encoding and decoding but as you mentioned your signals are decoding properly even with a "distorted signal” (which I think means a non-rectangular looking signal you are seeing on your scope). Welcome to the magic of both digital technology in general and of test equipment in particular that lets us both quantifiably measure and visually observe electricity as it is manipulated for various purposes including the ability to represent digital (binary) data riding upon analog (continuously variable) signals.
I have seen a test at 250 MHz too, sinus signal of course, I was thinking it should work correctly with rectangular signal at frequencies higher than 2 MHz, at least the SPI frequencies. Anyway, on SPI the decoding works very well even with that distorted signal.
Be sure that 1) signal source can really produce square wave of that frequency 2) you have 10x probes 3) proper probe compensation 4) proper probing techniques.