40 Hz Square wave with 8kHz tone

Yes. The wokwi simulator, in some odd cases, does not run at real time rates. This can make for some temporary panic attacks when you don't notice that's what's happening.

But millis(), the timers &c. and, as @koepel points out, the build in logic analyser available will all report identically to real life.

The only thing wrong with the logic analyser is that it might make you want one, a real one. Fortunately very serviceable units can be found, and free software to drive them.

This isn't the one I bought, but looks like it came out of the same factory:

https://www.amazon.com/Comidox-Analyzer-Device-Channel-Arduino/dp/B07KW445DJ


It was a disappointment until I ditched the cheap USB cable it came with. I use it with PulseView. I tried it with the Salea software and that, too, worked well.

HTH

a7