AnsweredAssumed Answered

Issue with USB when clocking from PLL0 in K70 TWR module.

Question asked by PRAMOD K. G. on Jun 13, 2014

Hi everyone,


                             I am working with K70 TWR module with MQX and CW10. In my project i want to run cpu at 120MHz frequency  from  50MHz ext oscr at certain times. All the other time the cpu should be run at 24MHz  from external 12MHz crystal. So I created a PLL0 configuration in BSP (copied and modified configuration 0)  to generate 24 Mhz frequency from 12 MHz. Now i can run the module at 24MHz, but there is some  issue with USB.  I configured USB as MSD mode (SD card) and it is working in 24Mhz mode whenever J19 jumper is connected. But it is not working when that jumper is removed, even though it is clocked from external 12 Mhz. Finany I want to disable this 50 Mhz oscr when device is clocked from 12 Mhz in the custom board. So this will be an issue.  I am attaching my configuration and screenshot of registers after configuration. Please let me know if there is something wrong,






  /* Switch to PEE Mode */
  /* OSC0_CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
  OSC0_CR = (uint8_t)0x80U;                       
  /* MCG_C10: LOCRE2=0,??=0,RANGE1=2,HGO1=1,EREFS1=1,??=0,??=0 */
  MCG_C10 = (uint8_t)0x2CU;                       
  /* OSC1_CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
  OSC1_CR = (uint8_t)0x80U;                       
  MCG_C1 = (uint8_t)0x28U;                       
  /* MCG_C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=0,LP=0,IRCS=1 */
  MCG_C2 = (uint8_t)0x21U;                       
  MCG_C11 = (uint8_t)0x04U;                       
  /* MCG_C11: PLLCLKEN1=1 */
  MCG_C11 |= (uint8_t)0x40U;   /* Enable the PLL */
  /* MCG_C12: LOLIE1=0,??=0,CME2=0,VDIV1=8 */
  MCG_C12 = (uint8_t)0x08U;                       
  /* MCG_C5: PLLREFSEL0=0,PLLCLKEN0=0,PLLSTEN0=0,??=0,??=0,PRDIV0=4 */
  MCG_C5 = (uint8_t)0x80U; 
//  MCG_C5 |= (uint8_t)0x40U; 
  /* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=8 */
  MCG_C6 = (uint8_t)0x44U;                       
  while((MCG_S & 0x0CU) != 0x0CU) { /* Wait until output of the PLL is selected */