How to change Main stack pointer value

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

How to change Main stack pointer value

2,100 Views
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 Kudos
Reply
1 Reply

2,089 Views
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 Kudos
Reply