Minimal code in Thonny. "set_init=rp2.PIO.OUT_LOW" means that this program controls just 1 pin, it's an output, and it's initially set to low. GPIO pin number 16 is set in the StateMachine call, "freq" is the PIO program clock speed in Hz. There are 2 instructions taking 1 cycle each, so "8000000" results in a 4 MHz square wave.
Oscilloscope screen shot, 4 MHz. The Vpp is just beginning to drop at this frequency, and the frequency itself isn't very accurate anymore.
Oscilloscope screen shot, 1 MHz. Seems workable.