AnsweredAssumed Answered

The question about K64

Question asked by Robin Zou on Sep 16, 2014
Latest reply on Sep 17, 2014 by Robin Zou

My device is MK64FN1M0VMD12.The hardware is TWR-K64F120M. My compiler is IAR 7.2.

I have write a bootloader.

There are two parts for my program.


 

Boot loader 1


 

 

INTERRUPT VECTOR TABLE


 

 

1KB($00000000-$000003FF)


 

 

NONVOLATILE REGISTERS(FLASH CONFIGURATION)


 

 

16 bytes ($00000400-$0000040F)


 

 

BOOT LOADER 1


 

 

3056 bytes($00000410-$00000FFF)


 

 

Boot loader 2


 

 

RELOCATED INTERRUPT VECTOR TABLE


 

 

1KB($00001000-$000013FF)


 

 

BOOT LOADER 2


 

 

31KB($00001400-$00008FFF)


 

 

 

I write the program in the Boot loader 1 to jump to Boot loader 2.

 

  #define RELOCATED_VECTORS 0x1000

 

SCB_VTOR =
RELOCATED_VECTORS;

 

JumpToUserApplication(*((unsigned
long*)RELOCATED_VECTORS), *((unsigned long*)(RELOCATED_VECTORS+4)));

 

void JumpToUserApplication(LWord userSP, LWord userStartup)

{

 

// set up stack
pointer

 

  __asm("msr msp, r0");

 

  __asm("msr psp, r0");

 

  // Jump to PC (r1)

 

  __asm("mov pc, r1");

 

 

}             

 

 

Before I adding the source code(as follow shown). The Boot loader 1 jumps to Boot loader 2 normally.

__root const unsigned char FlashCheck1_user @ 0x2fff ;

__root const unsigned char FlashCheck2_user @ 0x4fff;

__root const unsigned char FlashCheck3_user @ 0x6fff;

__root const unsigned char FlashCheck4_user @ 0x8fff;

 

After I adding the source code(as follow above). The Boot loader 1 can not  jumps to Bootloader 2 normally.

 

Sometimes the program runs normally.But sometimes the program cannot run normally.It stops in
the source code(as shown below) of Boot loader 2.

 

while((MCG->S & MCG_S_LOCK0_MASK) == 0x00U) { /* Wait
until PLL is locked*/  }

 

Can anyone tell me the reason? Thank you very much.

Outcomes