This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

compiled issue when code size exceed 64k on MSP430FG4619

Other Parts Discussed in Thread: MSP430FG4619

Hi Sir,

I have an issue that I use MSP430FG4619 and it's Flash size is 120K bytes and the code was implemented by assembly in IAR6.1.

firstly that I found when the code exceed 64k or 0xFFFF then compile will fail and shows Range error like as below image(I didn't modify .xcl):

I think that may need to use CALLA instruction instead the CALL to jump the address longer then 16bit and I have modified

all of CALL to CALLA but the compile made the reset address to 0x0000 and all code org was start from 0x10000, pls reference .map as below:

and the .txt is as below:

would you please help me to fix the issue? and any body can teach me how to correctly use the instruction "CALLA"?

I tried many methods like fix function address or constant data address after 0x10000~0x1FFFF but

it's seems not workable.

Thank you

Jerrel 

  • Hi!

    The MSP430 reset vector is two bytes, which mean that the reset handler, and all interrupt service routines, must be placed in the lower 64KB of memory.

    In the IAR tools, you can do this by placing your interrupt service routines and the reset handler in the ISR_CODE segment (rather than CODE), as this will not be placed over 64 KB (assuming that you use the supplied linker command files).

    Apart from that, you will have to change all your CALL:s to CALLA:s, all your RET:s to RETA:s, and compensate for the fact that the return address now takes up four bytes on the stack. The latter is important if you, for example, pass parameters to your assembly functions on the stack.

    You can take a look at the "macros.s43" file, which is part of the IAR run-time library. It provides a number of macros that expand to relevant instructions depending on the compiler settings. E.g. If you use the large code model, FCALL will expand to CALLA etc. (You might need to upgrade your tool to make the assembler see all settings, though.)

    -- Anders Lindgren, IAR Systems, Author of the IAR compiler for MSP430
  • Hi Sir,

    many thanks for your answer.

    I found if use default .xcl of MSP430FG4619 and turn all CALL, RET to CALLA, RETA when code exceed 64K and compiler will make

    ISR and CODE over 64K (start from 0x10000) and I didn't modify .xcl and the ISR_CODE,CODE16=2100-FFBF  and -P(CODE)CODE=2100-FFBF,10000-1FFFF.

    finally I add new memory range label CODE20 in .xcl as -P(CODE)CODE20=10000-1FFFF, and use rseg CODE20:CODE

    to org all function addr after 0x10000 and turn CALL, RET to CALLA,RETA then it is workable and the code reset addr

    is at 0x2100.

    I think this problem was be fixed but I have a concern that why compiler can't auto manage the ISR_CODE and CODE memory

    org range 0x2100~0xFFFF and 0x10000~0x1FFFF separately?

    thanks for your help

    Jerrel 

  • Jerrel Liao said:

    I think this problem was be fixed but I have a concern that why compiler can't auto manage the ISR_CODE and CODE memory

    org range 0x2100~0xFFFF and 0x10000~0x1FFFF separately?

    The compiler auto manages plain code and interrupt code. If you write your application in assembly, if you to stick to the conventions used by the compiler and link file, they will be managed as well.

    The only difference to your approach is that the compiler places interrupt code below 64KB and plain code anywhere in memory (when the large code model is used), whereas you wanted to explicitly place it above 64KB. To get the later from the compiler, the easiest way is to edit the CODE entry in the linker command file.

        -- Anders Lindgren, Author of the IAR compiler for MSP430

**Attention** This is a public forum