pragma udata not taken into account

Help
Landru31
2012-05-16
2013-03-12
  • Landru31
    Landru31
    2012-05-16

    I do not understand why #pragma udata is not taken into account :

    Here is my source file

    #include <pic18f4550.h>
    #pragma udata usbram5 foo
    char foo[10] = {0,1,2,3,4,5,6,7,8,9};
    void main() {
        while(1) ;
    }
    

    and here is the 18f4550.lkr

    LIBPATH .
    CODEPAGE   NAME=page       START=0x0               END=0x7FFF
    CODEPAGE   NAME=idlocs     START=0x200000          END=0x200007       PROTECTED
    CODEPAGE   NAME=config     START=0x300000          END=0x30000D       PROTECTED
    CODEPAGE   NAME=devid      START=0x3FFFFE          END=0x3FFFFF       PROTECTED
    CODEPAGE   NAME=eedata     START=0xF00000          END=0xF000FF       PROTECTED
    ACCESSBANK NAME=accessram  START=0x0            END=0x5F
    DATABANK   NAME=gpr0       START=0x60           END=0xFF
    DATABANK   NAME=gpr1       START=0x100          END=0x1FF
    DATABANK   NAME=gpr2       START=0x200          END=0x2FF
    DATABANK   NAME=gpr3       START=0x300          END=0x3FF
    DATABANK   NAME=usb4       START=0x400          END=0x4FF          PROTECTED
    DATABANK   NAME=usb5       START=0x500          END=0x5FF          PROTECTED
    DATABANK   NAME=usb6       START=0x600          END=0x6FF          PROTECTED
    DATABANK   NAME=usb7       START=0x700          END=0x7FF          PROTECTED
    ACCESSBANK NAME=accesssfr  START=0xF60          END=0xFFF          PROTECTED
    SECTION    NAME=CONFIG     ROM=config
    SECTION    NAME=bank1      RAM=gpr1
    SECTION    NAME=usbram4    RAM=usb4
    SECTION    NAME=usbram5    RAM=usb5
    SECTION    NAME=usbram6    RAM=usb6
    SECTION    NAME=usbram7    RAM=usb7
    

    When I open the Hex file, the data 00010203040506070809 is not in the 0x0500 bank !

    Does anyone has an idea ?

     
  • Erik Hammer
    Erik Hammer
    2012-05-28

    Hi,
    You are using #pragma udata which should only be used for uninitialized variables. Your array isn't being taken into account because you have initialized it.  Use #pragma idata for initialized variables. Should fix your problem.