run function from ram

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

cross mob
User16189
Level 1
Level 1
Hi,

My goal is to evaluate how fast I can toggle an I/O on the XMC1100.
For this, I bought the cute XMC 2Go kit and installed DAVE4.
Starting point was the XMC_2Go_Initial_Start_v1.3 example.
I can change the frequency of the blinking led. Toolchain works. Fine.


Then I added the line
P0_5_toggle();
In a while(1) loop.

Toggling works and time from rise to fall is about 3us.
Really slow.

According the comments in the example, the CPU clock is running on 8 Mhz.
Not sure how this works, but I need the 32 Mhz.
Changed the configuration to :
SCU_CLK->CLKCR = 0x0FFC0100UL;

This resulted in toggle time of about 1.2 us.

After this, I replace the function call to P0_5_toggle() with it's contents:
PORT0->OMR = 0x00200020UL;

This resulted in an improvement to about 530ns.


Oops! The tooling neglects the inline directive of the P0_5_toggle() function. No idea why.

Next step is to execute the toggle code from RAM.

Therefore, I move the toggling code to a separate function in a separate file.
In the function declaration, I added the famous __attribute__((section(".ram_code")))
However, the tooling also neglects this directive, and the code is still executed from flash.

Anybody knows a solution?
It seems that it is a tooling issue.
I tried to understand the linker script, but I did not see strange things.

Thanks,

Lodewijk
--

An investigation of the 530 ns:
The P0_5_toggle() generates 3 assembly instructions (2 loads and 1 store):
LDR: 2 cycles
LDR: 2 cycles
STR: 2 cycles
+ a B(ranch) for the while loop of 3 cycles

So, this is 9 cycles. If we assume 2 wait cycles for reading from flash, we have 8 additional cycles.
In total 17 cycles. 17 cycles * 31ns = 527ns.
0 Likes
1 Reply
TestJonas
Employee
Employee
This is a test post by IT
0 Likes