Hi,
I refer to the application: AN12384,but can't get it work, I don't know why!Can you help me,or give an example.Thanks!
here is my code:
#define SECTOR_1_START 0x00008000
typedef volatile uint32_t vu32;
typedef void (*voidfun)(void);
void IAP_LoadApp(uint32_t appxaddr)
{
if(((*(vu32*)appxaddr)&0x20000000) == 0x20000000) //0x20000000
{
voidfun firmwareFunc;
uint32_t fwStackVal = *((uint32_t *)(appxaddr)); /* the first word is for the stack pointer. */
uint32_t fwEntryVal = *((uint32_t *)(appxaddr+4U)); /* the second works is for the boot function. */
printf("fwStackVal: %x\r\n", fwStackVal);
printf("fwEntryVal: %x\r\n", fwEntryVal);
__disable_irq();
firmwareFunc = (voidfun)fwEntryVal;
SCB->VTOR = appxaddr; /* The stack address is also the start address of vector. */
__set_MSP(fwStackVal); /* setup the stack address for MSP. */
__set_PSP(fwStackVal); /* setpu the stack address for PSP. */
firmwareFunc();
}
else
{
printf("Code in Flash is Error\r\n");
}
}
int main(void)
{
get_clk();
#if (1 == PRINTF)
uart_init(DEBUG_UART, DEBUG_UART_BAUD, DEBUG_UART_TX_PIN, DEBUG_UART_RX_PIN);
#endif
pint_init(PINT_CH0, B2,LOW);
pint_enable_irq(PINT_CH0);
EnableInterrupts; //
#ifdef BOOT_CODE
printf("BOOT goto main()\r\n");
IAP_LoadApp(SECTOR_1_START);
#endif
#ifdef APP_CODE
printf("APP goto main()\r\n");
#endif
while(1)
{
}
}
here is my config:


