infineon4engi@twitter twitter

infineon4engineers Facebook

infineon@linkedin linkedin

infineon@youtube youtube


+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Beginner Beginner ltsmit is on a distinguished road
    Join Date
    Dec 2018
    Posts
    9
    Points
    57.5

    execute function from ram

    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.
    Last edited by ltsmit; Dec 7th, 2018 at 04:16 AM.

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.