The technical specifications show that the maximum clock frequency for MKV58xxx is 240 MHz (HSRUN).
The maximum frequency for the Peripheral (Fast Peripheral Clock) is 120 MHz, with the requirement to have at least /2 the CPU frequency.
So if the CPU has the clock at 240 MHz you can get 120 MHz on the peripherals. And all right here.
Unfortunately in the documentation (https://www.nxp.com/docs/en/reference-manual/KV5XP144M240RM.pdf paragraph 8.7 page 132) it is written that the flash memory not be programmed or erased while operating in High Speed Run (HSRUN).
For this reason, you must set the maximum allowed frequency for "Normal Run" mode: 160 MHz. By reducing CPU frequency to this value, unfortunately we also get the frequency of peripherals to become 80 MHz, really poor.
I wonder: what is the point of having an MCU that can work at 240 MHz and then have to limit it to 160 MHz due to flash memory?
It is not permissible to switch mode from HSRUN to NORMAL RUN during Flash programming, because all peripherals would change their operating frequency. In the case of motor control everything is a problem. The frequency must be set at the start and that must be set for the whole time. We are not talking about a smartphone that needs to save the battery.
It may happen that my drive need to save parameters on the flash memory while the motor is running controlled by my inverter.
Does anyone tell me why this bad choice was made?