Hi Vinicius,
indeed, I confirm the problem :-(.
The issue is about BUS vs . CORE clock speed. For the wait ns and us macros, it was using the BUS instead of (correctly) using the CORE clock speed. So as long you have the bus clock speed matching the core clock speed, you are fine. So if your core clock speed is three times the bus clock speed, the time waiting was three times too short.
I h ave fixed this on GitHub in case you are interested:
https://github.com/ErichStyger/McuOnEclipse_PEx/commit/96091726c9b600d611bf46db8c5ebfa0d35987cf
I have attached the fixed WAIT component to this post. I have not formally tested it, but using my FRDM-K20D50 board I'm able to get a 563us (for 500 us specified) waiting time at 48 MHz core clock speed and 24 MHz bus clock speed which matches the expectation, without any compiler optimization.
I appologize for the problem, and hope this helps you.
Best regards,
Erich