running code from internal sram
hey there.
for a while ive been tryin to copy some codes from flash to internal sram and run it.
ive read the datasheet, programming manual and cortex manual and they all confirm that it is possible to run code from sram, however when i copy the codes i get aforced hardfault which with durther inspection i realized is a bus fault indeed. i tried it on both stm32f103 and stm32f407 and its not working on either. here is the assembly function im copying into the sram:
myadd PROC
EXPORT myadd [WEAK]
NOP
NOP
BX lr
ENDP
and here is the function that copies and runs the copied code:
void test()
{
memcpy((void *)(SRAM_BASE + 0x100), &myadd, 200);
Delay(500);
//void (*func)() = (void (*)())((int32_t)(SRAM_BASE + 0x100) | 0x1);
void (*func)() = (void (*)())((int32_t)(SRAM_BASE + 0x100) | 0x1);
func();
}
during the error i only get bus imprecise error and other flags are zero.
anybody can see any problem with my code or its just that stm32 mcus cannot run code from sram or should i configure some cortex peripherals?
