This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Improving performace by moving code from Flash to RAM

Dear All,

I am upgrading a piece of software, having an small interruppt routine triggered every 100us.

I now have a problem with getting the CPU doing anything else...

The system consists of a C167CR-LM running at 16 MHz with an external 8bit FLASH, non mux.

I am considering moving the interrupt routine to internal RAM and execute it from there and thereby get a reduced execution time by a factor 2-3.

I have been studying the application note 138, but finds it rather tricky, isn't there any easier way to do this?

Is the code generated by the compiler relocatable or do I have to rewrite the routine in assembly code?

Comments appriciated.

/Rolf

  • I am considering moving the interrupt routine to internal RAM and execute it from there and thereby get a reduced execution time by a factor 2-3.

    Make sure you put the routine in XRAM rather than IRAM. IRAM is slow when it comes to code execution.

    I have been studying the application note 138, but finds it rather tricky, isn't there any easier way to do this?

    I doubt it can be much easier than AppNote 138.

    Is the code generated by the compiler relocatable or do I have to rewrite the routine in assembly code?

    You cannot assume that the compiler and linker generate relocatable code. It can turn out to be relocatable for some routines, but you cannot count on that, of course. AppNote 138 says that you can specify store address and execution address of a section. The store address is where the linker puts the section (in the HEX file). The execution address is where the section expects to be during execution. Normally they are the same for a given section. You can have them to be different in which case you have to copy the section from the store area to the execution area before executing code in that section.
    Hope this helps.

    - mike

  • Hi Mike,
    Thanks for your prompt reply.

    I am considering moving the interrupt routine to internal RAM and execute it from there and thereby get a reduced execution time by a factor 2-3.

    Make sure you put the routine in XRAM rather than IRAM. IRAM is slow when it comes to code execution.

    OK.

    I have been studying the application note 138, but finds it rather tricky, isn't there any easier way to do this?

    I doubt it can be much easier than AppNote 138.

    Is the code generated by the compiler relocatable or do I have to rewrite the routine in assembly code?

    You cannot assume that the compiler and linker generate relocatable code. It can turn out to be relocatable for some routines, but you cannot count on that, of course. AppNote 138 says that you can specify store address and execution address of a section. The store address is where the linker puts the section (in the HEX file). The execution address is where the section expects to be during execution. Normally they are the same for a given section. You can have them to be different in which case you have to copy the section from the store area to the execution area before executing code in that section.
    Hope this helps.

    Do you have any experience implementing this?
    Seems to take some effort to get into...

    btw. would it be possible to do the assemblycode inline, mixed with C-Code to make it easier to maintain ?

    regards,
    Rolf


    - mike

  • Rolf, Mike did you solve this problem?
    I have the same one. I want to relocate function from ROM to XRAM using its pointer, but it don't want to start.