We have a custom board using a Kinetis MK66FX1M0VMD18 connecting to a PC using USB VCOM (COM port on the PC). We use the interface to send commands to the MCU. One command involves internal flash write, and this makes it necessary to lower the MCU clock from 120MHz to below 80MHz. When I change the clock (this does not change the USB clock), the USB function stops sending. Receive seems to still be working.
I have traced the problem down to the USB_DeviceCdcAcmSend() function where cdcAcmPipe->isBusy is true and thereby leaving the function.
Setting the MCU clock back to its previous state does not help. What does help is to disconnect the USB cable (The device is self powered) and reconnect it. Doing this the "blocked" data present in the USB send buffer gets sent, and everything works until next time the clock is changed.
The USB clock is based on external 50MHz oscillator -> PLL (/5 *24) -> /2 -> USB1PFD clock (120MHz) -> *2 /5 -> 48MHz USB FS clock
Changing the core, system, bus and flash clocks only involves changing OUTDIV1,2,3 and 4 registers.
- Why does the clock change lock USB send, even dough I do not change the clock used by the USB interface ?
- How can I recover from a USB lock situation without having to disconnect the USB cable? (I have a similar problem maybe related to this one, but not involving a clock change)