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.

How to place one function on a n-byte boundary in IAR?

#pragma or other approach.

  • #pragma location = "MY_LOCATION"

    Then specify where MY_LOCATION should be in the linker file

    Look at the sleep code (hal_sleep.c) in any of the TI example apps for an example. The function halSetSleepMode() is placed on a 4 byte boundary.

    See the IAR users guide for an in depth explination

  • Peter Borenstein,

    thanks for your help.

    Just lik MASM,there is macro-instruction 'EVEN','ALIGN n' align the code,it's so convinent.

    I have tried to search something like that in IAR 51's compiler reference,but failed.

    Maybe,the way you mentioned is the only way,after all,the offical code is using this. |||-_-.