cancel
Showing results for 
Search instead for 
Did you mean: 

Implement function in RAM

nooshin_1382
Associate II
Posted on September 28, 2015 at 14:11

Hello Forum members,

I am trying to implement a Function On RAM But i did not find any thing on st Refrences.

I found this example in freescale but spcstudio can not compile the code .

__declspec(section ''.text_in_ram'')

static void EnterStandbyFromSRAM(void)

{

    /* Switch off the IRC fast */   

    ME.STANDBY0.B.IRCON = 0;

   

    /* keep flashes power off in DRUN */   

    ME.DRUN.B.DFLAON = 0b01;

    ME.DRUN.B.CFLAON = 0b01;

   

    /* configure fast wakeup from backup SRAM */

    RGM.STDBY.R = 0x0080;

   

    ME.MCTL.R = 0xD0005AF0; /* Enter STANDBY0 Mode & Key */

    ME.MCTL.R = 0xD000A50F; /* Enter STANDBY0 Mode & Inverted Key */

   

    /* it is recommended to poll S_MTRANS after requesting */

    /* STOP, HALT or STANDBY modes */

    while(1 == ME.GS.B.S_MTRANS)

    {       

    }

}

Thanks

Best Regards

Nazerian Vanima
7 REPLIES 7
Erwan YVIN
ST Employee
Posted on October 01, 2015 at 17:30

Hello Vanima ,

first declare your section attribute :

__attribute__ ((section (

''.codeinram''

)))

void

function_in_ram()
{
.....
}

update your application.ld :

.codeinram : ONLY_IF_RO
{
KEEP(*(.codeinram))
} > ram
/* before heap_base *§
 __heap_base__ = __bss_end__;
 __heap_end__ = __ram_end__;

In my case , the function is well in RAM. Best regards Erwan
nooshin_1382
Associate II
Posted on October 03, 2015 at 07:29

Hi Dear Erwan

Thanks So much For Solving about this issue .

I saw application.ld and do know any refrence about this file ?

Like what is this file and how can write my own application.ld .

Best Regards

Nazerian Vanima

nooshin_1382
Associate II
Posted on October 03, 2015 at 07:56

Hi Erwan

I compile the code but how can i find the code correctly is in ram ?

Best Regards

Nazerian Vanima

nooshin_1382
Associate II
Posted on October 03, 2015 at 09:44

Hi Erwan

I have Some Problems with using the code :

1.Compiling the code is very slow and when the compile is finish the out.bin file size is 1GB !!!

2.when the program want to run the function break detect in program.

I attach my code and appliction.ld for you , if there is any thing wrong Please let me know about this .

Erwan YVIN
ST Employee
Posted on October 05, 2015 at 10:02

Hello Vanima ,

I have reproduced your issue

the binary file is 1GB

i am checking why ?

Best regards

                 Erwan

nooshin_1382
Associate II
Posted on October 05, 2015 at 12:24

Hi Erwan

thanks so much i wait for your answer .

could you see my code is there any thing wrong in my code for RAM function ?

Please let me know about the standby mode i can not solve this issue yet .

Best Regards

Nazerian Vanima

Erwan YVIN
ST Employee
Posted on October 06, 2015 at 11:10 Hello Vanima , Ok i have understood the issue the image file is 1GB because objcopy will create some stubs between small adresses and 0x40 X. it is the debugger work. you should relocate your code in flash in application.ld to prevent from huge binary files. Could you try this ? Add :

.data : AT(__romdata_start__)
{
. = ALIGN(4);
__data_start__ = .;
*(.codeinram)
*(.data)
*(.data.*)
*(.gnu.linkonce.d.*)
__sdata_start__ = . + 0x8000;
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s.*)
__data_end__ = .;
} > ram

Remove :

.codeinram : ONLY_IF_RO
{
KEEP(*(.codeinram))
} > ram

your code stays valid.

warning ,

Update application.ld after generation the code make all Compiling hal.c In file included from ./components/portable_spc5_hal_component/lib/include/hal.h:32:0, from ./components/portable_spc5_hal_component/lib/src/hal.c:25: ./components/spc560bcxx_hal_drivers_component/lib/include/hal_lld.h:704:2: error: #error ''SPC5_FMPLL0_CLK outside acceptable range (0...SPC5_FMPLL0_CLK_MAX)'' make: *** [build/obj/hal.o] Error 1 Best regards Erwan