Hi,
I've tried run code from ram. My code is
#pragma segment="RAMCODE" #pragma segment="ROMCODE" /******************************************************************************* * LOCAL FUNCTIONS */ /* place the next function in RAMCODE */ #pragma location="RAMCODE" void LedOnFunc(void) { LED_ON } /* enable IAR extensions, this is necessary to get __sfb and __sfe, it is of course possible to write this function in assembler instead */ #pragma language=extended void init_ram_code() { void * ram_start = __sfb("RAMCODE"); /* start of RAMCODE */ void * ram_end = __sfe("RAMCODE"); /* end of RAMCODE */ void * rom_start = __sfb("ROMCODE"); /* start of ROMCODE */ /* compute the number of bytes to copy */ unsigned long size = (unsigned long)(ram_end) - (unsigned long)(ram_start); /* copy the contents of ROMCODE to RAMCODE */ memcpy( ram_start, rom_start, size ); } /* restore the previous mode */ #pragma language=default /******************************************************************************* * @fn main * * @brief Main program * * @param void * * @return int (does not return) */ int main(void) { /* Initialize Clock Source (32 Mhz Xtal), * global interrupt (EA=1), I/O ports and pheripherals(LCD). */ halBoardInit(); init_ram_code(); MEMCTR |= 0x08; LedOnFunc(); for(;;) }
I've add
-QRAMCODE=ROMCODE
-Z(DATA)RAMCODE=0x1E00-0x1F00
-Z(CODE)ROMCODE=0x4000-0x7FFF
to linker file.
The function LedOnFunc() works but from address 0x4000 checked by debugger. If I comment init_ram_code() LedOnFunc() works whatever. So how I can check the function run from RAM?