Not applicable
Jan 13, 2014
01:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 13, 2014
01:02 AM
If you would like to run a particular function (eg. MyFunction_SRAM()) from PSRAM to enhance the code execution speed. You can make some changes in both startup file (eg. startup_XMC4500.s) and linker descript file (*.ld):
1) Define a new section in *.ld before "/*Heap - Bank1*/"
2) Add a copy process in startup_XMC4500.s before "SKIPSRAMCODECOPY:"
3) Declare function in program
With these, the function MyFunction_SRAM will be located in section SRAMCode. It will be copied to PSRAM in startup code and then run from PSRAM.
1) Define a new section in *.ld before "/*Heap - Bank1*/"
/*=== SRAMCode section for PSRAM code ============*/
SRAMCodeLoad = eROData + __Xmc4500_Data_Size;
SRAMCode_Section : AT (SRAMCodeLoad)
{
SRAMCodeStart = ABSOLUTE(.);
* (.SRAMCode);
. = ALIGN(4);
SRAMCodeEnd = ABSOLUTE(.);
} > PSRAM_1
SRAMCodeSize = SRAMCodeEnd - SRAMCodeStart;
2) Add a copy process in startup_XMC4500.s before "SKIPSRAMCODECOPY:"
/*========== SRAM code copy ===========================*/
SKIPDATACOPY:
/* R0 = Start address, R1 = Destination address, R2 = Size */
LDR R0, =SRAMCodeLoad
LDR R1, =SRAMCodeStart
LDR R2, =SRAMCodeSize
/* Is there anything to be copied? */
CMP R2,#0
BEQ SKIPSRAMCODECOPY
/* For bytecount less than 4, at least 1 word must be copied */
CMP R2,#4
BCS STARTSRAMCODECOPY
/* Byte count < 4 ; so bump it up */
MOV R2,#4
STARTSRAMCODECOPY:
/*
R2 contains byte count. Change it to word count. It is ensured in the
linker script that the length is always word aligned.
*/
LSR R2,R2,#2 /* Divide by 4 to obtain word count */
/* The proverbial loop from the schooldays */
SRAMCODECOPYLOOP:
LDR R3,[R0]
STR R3,[R1]
SUBS R2,#1
BEQ SKIPSRAMCODECOPY
ADD R0,#4
ADD R1,#4
B SRAMCODECOPYLOOP
/*=================== end of Copy process =================*/
3) Declare function in program
void MyFunction_SRAM (void) __attribute__ ((section (".SRAMCode")));
With these, the function MyFunction_SRAM will be located in section SRAMCode. It will be copied to PSRAM in startup code and then run from PSRAM.
5 Replies
Not applicable
Jan 23, 2014
11:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 23, 2014
11:19 PM
Dear Sophia
I try this tips, but i can not found "SKIPSRAMCODECOPY" in my startup_XMC4500.s file.
The image show the error after i add the step 2 code in my Startup_XMC4500.s
I try this tips, but i can not found "SKIPSRAMCODECOPY" in my startup_XMC4500.s file.
The image show the error after i add the step 2 code in my Startup_XMC4500.s
Not applicable
Jan 24, 2014
12:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 24, 2014
12:35 AM
Hi Gun,
Sorry, forgot to mention that you need to change the "SKIPCOPY" to "SKIPSRAMCODECOPY:".
Best regards,
Sophia
Sorry, forgot to mention that you need to change the "SKIPCOPY" to "SKIPSRAMCODECOPY:".
Best regards,
Sophia
Not applicable
Jan 24, 2014
01:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 24, 2014
01:37 AM
Hi Sophia
After i change all mentioned "SKIPCOPY" to "SKIPSRAMCODECOPY" in file Startup_XMC4500.s, the project successfully compiled.
I declared one of my function to be put in PSRAM
When the program being launched in the board, the debugger suddenly stop when reached the function void Motion_Control(void).
After i execute the single step (F5), the debugger window show "No source available for "0x10000328()" and the program completely stopped.
After i change all mentioned "SKIPCOPY" to "SKIPSRAMCODECOPY" in file Startup_XMC4500.s, the project successfully compiled.
I declared one of my function to be put in PSRAM
void Motion_Control(void) __attribute__ ((section (".SRAMCode")));
When the program being launched in the board, the debugger suddenly stop when reached the function void Motion_Control(void).
After i execute the single step (F5), the debugger window show "No source available for "0x10000328()" and the program completely stopped.
Attachments are accessible only for community members.
Not applicable
Jun 15, 2014
10:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 15, 2014
10:41 PM
Not applicable
Jun 16, 2014
01:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 16, 2014
01:37 AM
Hi,
There is an example project "FunctionLocated_in_RAM" available in the internet. Key word "Code in RAM".
Best regards,
Sophia
There is an example project "FunctionLocated_in_RAM" available in the internet. Key word "Code in RAM".
Best regards,
Sophia