How to change Main stack pointer value

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to change Main stack pointer value

1,588 次查看
AnwarSheik
Contributor I

Hi,

I recently started working on bootloader for s32k144. I am using s32ds for arm

can some one guide me how to change the MSP value to jump from bootloader to user application 

@JozefKozon @jann_ @guoweisun @TomasVaverka @lukaszadrapa

0 项奖励
1 回复

1,577 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@AnwarSheik

you can refer to AN12218 and AN12218SW,

https://www.nxp.com/search?keyword=AN12218&start=0 

and below demo code can be found in AN12218SW

/**
 * Used to jump to the entry point of the user application
 * The Vector table of the user application must be located at 0x1000
 *
 * */
void JumpToUserApplication( unsigned int userSP,  unsigned int userStartup)
{
	/* Check if Entry address is erased and return if erased */
	if(userSP == 0xFFFFFFFF){
		return;
	}

	/* Set up stack pointer */
	__asm("msr msp, r0");
	__asm("msr psp, r0");

	/* Relocate vector table */
	S32_SCB->VTOR = (uint32_t)APP_START_ADDRESS;

	/* Jump to application PC (r1) */
	__asm("mov pc, r1");
}

 

0 项奖励