I'm working on a custom board with CW10, MQX 3.8 and K60N512 processor.
With this board I have successfully worked with MQX 3.7. Now that I ported all custom drivers to MQX 3.8, everything is ok except the USB. I cloned the BSP twrk60n512 and I modified the line 58 in the bsp_cm.h file from
#define CPU_XTAL_CLK_HZ 0x02FAF080U /* Value of the external crystal or oscillator clock frequency in Hz */
#define CPU_XTAL_CLK_HZ 0x016E3600U /* Value of the external crystal or oscillator clock frequency in Hz */
(my external clock is 24 MHz instead of 50 MHz as in the twrk60n512 board)
When I insert the USB cable in the PC port the device is not recognized, even if leave the 50 MHz define.
The only way I found to make the USB work is to set the SIM_CLKDIV2.USBDIV field to 0 instead of 1 in the Cpu_SetClockConfiguration function: I modified the line 717 in the bsp_cm.c file from
SIM_CLKDIV2 = (uint32_t)((SIM_CLKDIV2 & (uint32_t)~0x0DUL) | (uint32_t)0x02UL); /* Update USB clock prescalers */
SIM_CLKDIV2 = (uint32_t)(SIM_CLKDIV2 & (uint32_t)~0x0FUL); /* Update USB clock prescalers */
Am I right or do I have to modifiy other things?
Any other advice?