Hello,
I am using Keil uVision 5.15 compiler. copying a routine to ram(FLASH_eraseOneBlock) and try to runit, the code crashes (hardware Fault). I have looked at Keil's ram function example and it does not work either. my code is:
typedef void (*FunctionPointer_t)(uint32_t ); FunctionPointer_t ramFunc; uint32_t executableRam[100]; void TxfrToRam(void) { uint32_t source,source_end; uint32_t *dest,addr; source = (uint32_t)&FLASH_eraseOneBlock; source_end = (uint32_t)source + 80; dest = (uint32_t *)executableRam; ramFunc = (FunctionPointer_t)dest; while (source < source_end) { *dest++ = *(uint32_t *)source++; } for (addr = 0x2000; addr < 0x20000; addr += FLASH_PAGE_SIZE) { ramFunc(addr); } }
Any help will be highly appreciated.
Thanks
Yash
Further update: I have verified that the code is copied correctly. It goes to the correct location. The disassembly shows it is correct code. The very first instruction in ram causes hard fault. When I copy the code The address in the variable is one more than the actual code, though I have corrected it. May be bit 0 of pc has a special meaning. Please help. Thanks Yash
community.nxp.com/.../113048
It uses the address of the destination to determine what instruction mode it jumps into. An even instruction address changes the instruction mode to ARM 7. An odd instruction address keeps the processor in Thumb mode.
View all questions in Keil forum