A quick PSA in case you're at a loss as to why you're seeing strange behaviour from your STM32 MCU pins when running higher frequencies through them like I was.
After successfully getting MCO (Microcontroller Clock Output) working on the only STM32L031 I could find in the universe, I was seeing some strange behaviour when attempting to push the output frequency above 2MHz.
If you look at the measurements at the bottom, the frequency is correct but why is the amplitude so low and where's that DC offset come from?!
let gpioa = dp.GPIOA.split;
let mco_pin = gpioa.pa8.set_speed;
set_speed modifies the
ospeedr register for the appropriate GPIO port. If you're not
using the HAL or Rust, check your datasheet for the correct values to set.
Now I can double the output frequency (8MHz) and get a far better defined squarewave:
I thought I'd experiment with
Speed::VeryHigh too using a single pulse.
Speed::High, zoomed in a little bit:
The rise time is more than twice as good as
Medium, giving us more frequency headroom.
There's a little bit more ringing, but that could be due to the PCB I'm using having quite long traces between the MCU and the test point the scope is attached to.
Rise time has improved a bit from
High (6ns down to 4ns) but the ringing has got a little bit