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

running from XRAM on XC878

Hi,

I am trying to run one function from XRAM on XC878. This works on other XC800 devices where XRAM is at 0xF000 but it seems that Microvision will not allows code to run from 0x2F000 where the XRAM is located on XC878.

I have a function that copies the compiled code from Flash to XRAM for execution from there.
Any ideas?

Best Regards
Jurgen

Parents
  • Ok. I need to tell the compiler that I want to execute a function from XRAM but have the function located in Flash, copied to XRAM at start-up then call the function.

    How do I do this for XC878? I have done it for other XC800 devices that don't have banking.

    This is how I am trying to do it but the missing part is how to tell the compiler where to run from and where to store the code in flash, specifically LED_CHANGE.

    void main(void)
    {

    MAIN_vInit();

    LED_CHANGE();

    while(1) { ; }

    } // End of function main

    #define XRAM_START (0x2F000) //start of XRAM
    #define F_XRAM_CODE (0x0896) //XRAM executable code in Flash, start
    #define F_XRAM_CODE_END 0x0899)//XRAM executable code in Flash, end

    void XRAM_vInit(void) { // move XRAM executable code from Flash to XRAM char code * fdata = F_XRAM_CODE; char xdata * xramdata = XRAM_START;

    do { *xramdata++ = *fdata++; } while( fdata < F_XRAM_CODE_END );
    } // End of XRAM_vInit()

    void LED_CHANGE(void)
    { IO_vWritePort(P3, 0xAA);
    }

Reply
  • Ok. I need to tell the compiler that I want to execute a function from XRAM but have the function located in Flash, copied to XRAM at start-up then call the function.

    How do I do this for XC878? I have done it for other XC800 devices that don't have banking.

    This is how I am trying to do it but the missing part is how to tell the compiler where to run from and where to store the code in flash, specifically LED_CHANGE.

    void main(void)
    {

    MAIN_vInit();

    LED_CHANGE();

    while(1) { ; }

    } // End of function main

    #define XRAM_START (0x2F000) //start of XRAM
    #define F_XRAM_CODE (0x0896) //XRAM executable code in Flash, start
    #define F_XRAM_CODE_END 0x0899)//XRAM executable code in Flash, end

    void XRAM_vInit(void) { // move XRAM executable code from Flash to XRAM char code * fdata = F_XRAM_CODE; char xdata * xramdata = XRAM_START;

    do { *xramdata++ = *fdata++; } while( fdata < F_XRAM_CODE_END );
    } // End of XRAM_vInit()

    void LED_CHANGE(void)
    { IO_vWritePort(P3, 0xAA);
    }

Children
  • Well, what little of that snippet is actually readable contains no trace of you even trying to get the compiler to call that function any differently than any other. How is the compiler to know that you don't want to just call function right there in CODE, where the linker put it, without you so much as dropping it a hint?

    And how did you even expect that copy loop to work? 0x2F000 is outside the addressable range of a plain pointer to xdata, so at the very least you'll have to make that a __far pointer or use some other XDATA paging mechanisms.