Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

pic16 and IDATA segment

bets
2007-10-09
2013-03-12
  • bets
    bets
    2007-10-09

    i'm trying to compile pic16 code on sdcc.

    I have two arrays statically defined: one to convert from scancodes to chars and one with char definitions for a screen:

    unsigned char scancode[256]={
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    ...

    unsigned char chmap[128][6]={
    { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    { 0x00, 0x06, 0x00, 0x00, 0x05, 0x01},
    ...

    this arrays should be in some way in the rom of pic, or i waste a lot of ram. The assembler is like this:

            idata
    _scancode       db      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            db      0x09, 0x00, 0x5c, 0x00, 0x00, 0x26, 0x27, 0x00, 0xc2, 0x51, 0x31, 0x00
            db  ....

    and compiling i receive this:

    warning: relocation of section ".idata" failed, relocating to a shared memory location
    error: linker script has no definition that matches the type of section ".idata"

    The segment IDATA is in ram? there is a workaround ?

    I was wondering if to change like this:

    unsigned char scancode(unsigned char c)
    { select case c
       ...
      //and return different values.
    };

    So all became functions, and i'm sure the array is stored in rom.

     
    • Steven
      Steven
      2007-10-09

      I believe that if you define the arrays as const, they will be placed in ROM.

      e.g.

      static const unsigned char scancode[256]={
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 

      Regards,

      Steven

       
    • The compiler needs to be told that the array contains constant (unchangeable) data, because, after all, changeable data must be allocated to RAM. The C syntax is:

      const unsigned char scancode[256]={
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
      ...