MEMORY { /* Define each memory region */ MFlash24 (rx) : ORIGIN = 0x1000, LENGTH = 0x5000 /* 20K bytes */ RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x1FE0 /* 8K bytes */ } /* Define a symbol for the top of each memory region */ __top_MFlash24 = 0x1000 + 0x5000; __top_RamLoc8 = 0x10000000 + 0x1FE0; |
int main(void) { LPC_IOCON->PIO2_9 &= ~0x1F; // PIO2_9, NO PULLUP/PULLDOW LPC_GPIO2->DIR |= (0x1 << 9); // 1 - OUTPUT SysTick_Config(SystemCoreClock / 100000000UL); while(1); return 0 ; } void SysTick_Handler(void) { if (u8LedOn) { (LPC_GPIO2->MASKED_ACCESS[(1 << 9)] = ((1) << 9)); } else { (LPC_GPIO2->MASKED_ACCESS[(1 << 9)] = ((0) << 9)); } u8LedOn = !u8LedOn; } |
/* Load main stack pointer with application stack pointer initial value, stored at first location of application area */ asm volatile("ldr r0, =0x1000"); asm volatile("ldr r0, [r0]"); asm volatile("mov sp, r0"); /* Load program counter with application reset vector address, located at second word of application area. */ asm volatile("ldr r0, =0x1004"); asm volatile("ldr r0, [r0]"); asm volatile("mov pc, r0"); |
static uint32_t u32BootLoader_ProgramFlash(uint8_t *pu8Data, uint16_t u16Len) { uint32_t u32Result = 0; static uint32_t u32NextFlashWriteAddr = APP_START_ADDR; if ((pu8Data != 0) && (u16Len != 0)) { /* Prepare the flash application sectors for reprogramming */ if (u32IAP_PrepareSectors(APP_START_SECTOR, APP_END_SECTOR) == IAP_STA_CMD_SUCCESS) { /* Ensure that amount of data written to flash is at minimum the size of a flash page */ if (u16Len < IAP_FLASH_PAGE_SIZE_BYTES) { u16Len = IAP_FLASH_PAGE_SIZE_BYTES; } /* Write the data to flash */ if (u32IAP_CopyRAMToFlash(u32NextFlashWriteAddr, (uint32_t)pu8Data, u16Len) == IAP_STA_CMD_SUCCESS) { /* Check that the write was successful */ if (u32IAP_Compare(u32NextFlashWriteAddr, (uint32_t)pu8Data, u16Len, 0) == IAP_STA_CMD_SUCCESS) { /* Write was successful */ u32NextFlashWriteAddr += u16Len; u32Result = 1; } } } } return (u32Result); } |
[color=#f00]//slow jump: switch main clock to IRC LPC_SYSCON->MAINCLKSEL = 0; LPC_SYSCON->MAINCLKUEN = 0; LPC_SYSCON->MAINCLKUEN = 1; [/color]/* Valid application located in the next sector(s) of flash so execute */ /* Load main stack pointer with application stack pointer initial value, stored at first location of application area */ asm volatile("ldr r0, =0x1000"); asm volatile("ldr r0, [r0]"); asm volatile("mov sp, r0"); /* Load program counter with application reset vector address, located at second word of application area. */ asm volatile("ldr r0, =0x1004"); asm volatile("ldr r0, [r0]"); asm volatile("mov pc, r0"); |
SysTick_Config(SystemCoreClock / 10); |
/* Setup SysTick Timer for 1 second interrupt */ SysTick_Config(SystemCoreClock / 100000000UL); |