MQX BSP code stuck on "Wait until external reference clock is selected as MCG output" on a Tower K70

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX BSP code stuck on "Wait until external reference clock is selected as MCG output" on a Tower K70

1,125 Views
rickstuart
Contributor V

Hi,

I have a K70 Tower setup and am not getting past a while loop in the BSP.  The comment is "Wait until external reference clock is selected as MCG output.".  This is line 990 in file bsp_cm.c.  The code is:

  while((MCG_S & 0x0CU) != 0x08U) {/* Wait until external reference clock is selected as MCG output */

I am fairly sure I have my jumpers in the processor board set up exactly like my co-worker's.  And he has been able to run his code just fine.  There are differences between my code and his.  But there should be no difference between at the BSP level.

Knowing what to look for (i.e. jumper configuration or code) would be a great help.

-thanks

0 Kudos
3 Replies

550 Views
rickstuart
Contributor V

If it helps, the BSP method the code is stuck in (infinite while loop) is "__pe_initialize_hardware()".  The description is: "Initializes the whole system like timing, external bus, etc. This method is internal. It is used by Processor Expert only.".  So, obviously, I'm treading on very thin ice here.  I tried commenting out the while loop.  But the code contains several such loops and execution gets stuck in a similar while loop several lines down.  Here's the code segment of this method:

/* 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;

  while((MCG_S & MCG_S_IREFST_MASK) != 0x00U) { /* Check that the source of the FLL reference clock is the external reference clock. */

  }

  while((MCG_S & 0x0CU) != 0x08U) {    /* Wait until external reference clock is selected as MCG output */   <===GETTING STUCK HERE!!!

  }

  /* Switch to PBE Mode */

  /* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=8 */

  MCG_C6 = (uint8_t)0x48U;

  while((MCG_S & 0x0CU) != 0x08U) {    /* Wait until external reference clock is selected as MCG output */

  }

  while((MCG_S & MCG_S_LOCK0_MASK) == 0x00U) { /* Wait until PLL locked */

  }

  /* Switch to PEE Mode */

  /* MCG_C1: CLKS=0,FRDIV=5,IREFS=0,IRCLKEN=0,IREFSTEN=0 */

  MCG_C1 = (uint8_t)0x28U;

  while((MCG_S & 0x0CU) != 0x0CU) {    /* Wait until output of the PLL is selected */

  }

-thanks

0 Kudos

550 Views
dereksnell
NXP Employee
NXP Employee

Hi Rick,

Please check the jumper settings on both your TWR-K70F120M board and the TWR-SER related to the clock. You can refer to the TWR-K70F120M section in the MQX Getting Started Guide, which documents these clock jumper settings needed for this MQX BSP.

This BSP is configured to use an external 50MHz oscillator as the clock source. The jumper settings give two options for this clock source. When using Ethernet, the clock source comes from the TWR-SER board as the clock is shared with the Ethernet PHY. There is also a 50MHz oscillator on the K70 card to enable stand-alone operation without Ethernet or TWR-SER board.

From your description, it appears the MCU is not getting this 50MHz clock source because of the jumper settings. Or another possibility is the Tower cards are backwards in the elevator cards, and then the 50MHz clock from the TWR-SER board is not routed to the K70. Be sure the primary card edge with the white stripe is inserted in the primary elevator with the white connectors, for all Tower cards. If that still doesn’t help, please check that the EXTAL0 pin of the K70 is receiving a 50MHz square wave.

Thanks

550 Views
rickstuart
Contributor V

I don't know how to create a URL directly to a single post in a thread.  So I'm going to refer to the post marked "

There it says: "Try opening your bsp and disable the RTC in processor expert. Also set BSPCFG_ENABLE_RTCDEV in user_config.h to 0.  I tried this but it did not solve my problem.  Of course, this other thread is about "custom board" and I am running on a Freescale K70 Tower. 

0 Kudos