In a spin loop waiting for external clock on K60 sample programs

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

In a spin loop waiting for external clock on K60 sample programs

1,222 Views
Keith4DSmith
Contributor V

I am working with the TWR-K60F120M evaulation board. I am using IAR Systems as my IDE.

Each time I try to run one of the examples, like mqx/examples/hello or the TWR-K60F102M_Quick_Start_Demo, I hang on the following line of code in bsp_cm.c

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

  }

I am using MQX 4.0.

Is there a patch or upgrade to fix this problem for the K60?

Labels (1)
0 Kudos
Reply
5 Replies

857 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Keith:

You might be facing the same issue described here:

Re: K10 crystal start problem at CW debug session

and here:

USB with the TWR-K60F120M and TWR-K70F120M | MCU on Eclipse

The workaround is to change MCG_C10[RANGE1] to 1 instead of 2. You will find this setting in the same bsp_cm.c


Regards!
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

857 Views
Keith4DSmith
Contributor V

Jorge - The code I have from MQX does not match the code from the code change from 'USB with the TWR-K60F120M...'

The USB code change also mentions changing MCG_C2. Is it necessary to change MCG_C2?

My code in bsp_cm.c was

  /* MCG_C10: LOCRE2=0,??=0,RANGE1=2,HGO1=1,EREFS1=1,??=0,??=0 */

  MCG_C10 = (uint8_t)0x2CU;                          

I changed it to

  /* MCG_C10: LOCRE2=0,??=0,RANGE1=1,HGO1=1,EREFS1=1,??=0,??=0 */

  MCG_C10 = (uint8_t)0x1CU;                          


Correct?


Also there are multiple settings of MCG_C10. Do they all have to be changed? or just the one prior to the hang?

0 Kudos
Reply

857 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi:

The USB code change also mentions changing MCG_C2. Is it necessary to change MCG_C2?

Mmm, I missed that, but yes, I think you need to change both.

Also there are multiple settings of MCG_C10. Do they all have to be changed? or just the one prior to the hang?

I see what you mean, there are references to MCG_C2 and MCG_C10 for different operating modes (PEE, PBE, FBE, etc.). These functions are of course not part of the initialization code, so it depends on which ones you will use in your application. I would change them all.

:smileyalert: Also please notice that due to the errata this problem apparently appears only when you are debugging, but should not affect in standalone mode.


Regards!
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

857 Views
Keith4DSmith
Contributor V

Unfortunately, these changes didn't fix the problem. I changed bsp_cm.c. I rebuilt the MQX libraries. I saw bsp_cm.c rebuild. I rebuilt the MQX 'hello world' example.

I hang in the same location.

MCG_C10 is 0x1C and MCG_C2 is 0x11. The original code had MCG_C10 set to 0x2C and MCG_C2 set to 0x21.

0 Kudos
Reply

857 Views
mjbcswitzerland
Specialist V

Hi

Do you have an external clock source connected to the processor?

Check the jumpers according to the table on page 9 of http://www.utasker.com/docs/KINETIS/uTaskerV1.4_Kinetis_demo.pdf

Regards

Mark

0 Kudos
Reply