Stuck in __pe_initialize_hardware after booting with custom bootloader

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

Stuck in __pe_initialize_hardware after booting with custom bootloader

579 Views
mikhailburakov
Contributor III

Hello community!

I prepared a custom bootloader prototype for my project, and it works fine. But i've stumbled upon a problem in initialization code of a flashed MQX system. It appears i can't get out of the following waiting loop in __pe_initialize_hardware function (generated cpu.c in bsp code):

  /* Switch to PEE Mode */
  /* MCG_C1: CLKS=0,FRDIV=3,IREFS=0,IRCLKEN=0,IREFSTEN=0 */
  MCG_C1 = (MCG_C1_CLKS(0x00) | MCG_C1_FRDIV(0x03));                                  
  while((MCG_S & 0x0CU) != 0x0CU) {    /* Wait until output of the PLL is selected */
  }

It seems to be waiting infinitely. But when i break the code execution (or make there a breakpoint, it does not matter), MCG_S appears to be in a required state. After this I hit continue and everything works as expected. Can someone shed a light on this behavior and maybe point me to some documentation, or give advice on any additional actions i must perform in my bootloader to avoid this situation?

0 Kudos
Reply
1 Reply

494 Views
mikhailburakov
Contributor III

Looks like the problem was with the oscillator configuration. I had to add "OSC_CR = 0" right before branching from the bootloader. This seemed to resolve the problem.

0 Kudos
Reply