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

Can I define an array variable in absolute address of code memory?

It's somewhat like look-up table of assembly. I defined an array in header file of C program like this:
unsigned char code volt_2_freq[5]=
{ 100, 200, 300, 400, 500 };
Can I put it in a specific address of code memory ?
I use Phillip LPC900 series MCU and want to set security bits of "MOVC disable" in certain program memory blocks which the array can't be put in.
Does keyword "_at_" work ?
Thanks~

willy

Parents
  • "Does keyword '_at_' work"

    The _at_ keyword works exactly as described in the Manual - unfortunately, that precludes initialisation! :-(

    This question is asked so frequently that it's amazing that Keil haven't removed the restriction yet!

    The solution is described in a knowledgebase article - use the site 'Search'; basically, you need to use the linker to set the address.

    "I use Phillip LPC900 series MCU and want to set security bits of 'MOVC disable' in certain program memory blocks which the array can't be put in."

    I don't think that's been mentioned before as a reason for doing it, though!

Reply
  • "Does keyword '_at_' work"

    The _at_ keyword works exactly as described in the Manual - unfortunately, that precludes initialisation! :-(

    This question is asked so frequently that it's amazing that Keil haven't removed the restriction yet!

    The solution is described in a knowledgebase article - use the site 'Search'; basically, you need to use the linker to set the address.

    "I use Phillip LPC900 series MCU and want to set security bits of 'MOVC disable' in certain program memory blocks which the array can't be put in."

    I don't think that's been mentioned before as a reason for doing it, though!

Children
  • instead of _AT_ I have all XDATA in an ASM module like (extract)

    ;;////////////////////////////////////////////////////////////////////
    ;;
    ;;  FILE:     SLVXDATA.A51
    ;;
    ;;  Copyright TwinVision N.A., 2006
    ;;
    ;;  Xdata buffers (in assembler to force sequence and XendOfMem define)
    
    $NOMOD51
    
    ;$INCLUDE   (sdefs.h)
    ;$INCLUDE   (msstruct.inc)
    
               PUBLIC GCXSinBuf
               PUBLIC GCXSouBuf
    .....
    ?XD?xdataf SEGMENT XDATA
               RSEG ?XD?xdataf
    ......
    
    ;; --- these located as early as possible for the sake of the speed of internal RAM
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; the next 5 buffers MUST be kept in the current order and contiguous
    
    GCX1_2Buf0: ds    01000h  ;byte per dot 256 cols, 4 rows
    GCX1_4Buf0: ds    01000h
    GCX1_8Buf0: ds    01000h
    ....
    


    then my .h file define all XDATA as extern

    Erik

  • "This question is asked so frequently that it's amazing that Keil haven't removed the restriction yet!"

    In fact, the version of _at_ in the ARM compiler does allow initialisation:
    http://www.keil.com/support/man/docs/ca/ca_le_absvarloc.htm

    So why can't C51 allow it??