switching code executions to RAM

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16898
Level 4
Level 4
User manual says to switch code execution from Flash to RAM during entering the standby mode page 506).

[HTML]CPU code execution is switched from Flash to PSPR RAM. Flash modules are
deactivated via FCON register.[/HTML]

There are no information about PSPR RAM register or how to switch this execution.
How can i do it ?

I work on Tc222L
0 Likes
6 Replies
cwunder
Employee
Employee
5 likes given 50 likes received 50 solutions authored
There are no information about PSPR RAM register or how to switch this execution.
How can i do it ?


The Program Scratch-Pad RAM (PSPR) is tightly coupled RAM located in the PMI with its own memory space. To execute from PSPR you would do like any other microcontroller to exectue from RAM. Generally you create an entery or section that has a storage address in (Flash) and execute address (RSM) and the copy table initialization moves it from Flash to RAM on startup. In your program you would call it like any other function.

For the Hightec toolchain you could do something like this:
__attribute__((asection(".cpu0_psram", "a=4", "f=xwc0")))
void TurnOffFlashEnterStandbyMode(void) {
unlock_wdtcon(0);
FLASH0_FCON.B.SLEEP = true;
lock_wdtcon(0);


while(false == FLASH0_FSR.B.SLM) {
; /*wait for flash to turn off */
/*TODO: add timeout if this fails */
}
...

Thank you so much for the anwser!! This is exactly what I am looking for. 

I follow your method and get the function load into RAM, at least from what the compile output .map file show. I am using Hightec toolchain and programming TC234.

User21797_0-1711611598067.png

I am getting ~10-15% runtime time reduction from function to function. Which is great. I measure the runtime with MCU's timer STM.

But is this speed gain normal?

Also can I put function into dram too?

0 Likes
User16898
Level 4
Level 4
thanks for Quick response.
unfortunetly
__attribute__((asection(".cpu0_psram", "a=4", "f=xwc0")))
is not recugnized by TASKING toolchain.
0 Likes
cwunder
Employee
Employee
5 likes given 50 likes received 50 solutions authored
For the Tasking toolchain you could do something like:

Where you need to add a section to the lsl file:

        
section_layout :vtc:linear
{
group pspr0 ( run_addr = mem:pspr0, copy )
{
select "*.myRamCode";
}
}


Then in your code


volatile int cnt;

__noinline void myRamCode( void )
{
cnt++;
}
0 Likes
User16898
Level 4
Level 4
after i placed suggested code I got following compiler error from .sls file :

syntax error: Could not find memory pspr0 for memory reference for a run-time or load-time address range of a group
0 Likes
User16898
Level 4
Level 4
Ok I found solution:

section_layout :tc0:linear
{
group STANDBY_MODE_RAM_FUNCTIONS(ordered, run_addr=mem : mpe : pspr0,copy)
{
select".text.ifx_standby_mode_psram.ifx_enter_standby_mode_psram_sequence";

select".text.IfxScuWdt.IfxScuWdt_clearSafetyEndinit";
select".text.IfxScuWdt.IfxScuWdt_setSafetyEndinit";

select".text.IfxScuWdt.IfxScuWdt_setCpuEndinit";
select".text.IfxScuWdt.IfxScuWdt_clearCpuEndinit";

}
}
0 Likes