• AVR Freaks

Hot!Adding loadable file in MPLAB project, but data is programmed at different address

Author
A.Rajesh
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2020/05/07 18:41:55
  • Location: 0
  • Status: offline
2020/05/08 21:43:48 (permalink)
0

Adding loadable file in MPLAB project, but data is programmed at different address

Hi,
I am using MPLAB 3.0, XC8 1.34, PICkit3, PIC16f1575 micro.
My goal is to place some data into a hex file, put that into project loadables, program the device.
Inside the program I would read flash memory, the addresses I read are those mentioned in the loadable hex file.
Here my loadable hex file name is masterData.hex,  I have some data at 0x1100 address, when I build the project, the data from masterData.hex file is inserted into \production\motorController.X.production.unified.hex file with address 0x1100, this is fine.
But when I go to Window->PIC Memory Views->Program Memory, the masterData.hex data is placed at 0x880 address instead of 0x1100, and the data is physically flashed at 0x880 only.
 why this is happening, and how place the data exactly where I wanted. Help please. Please see the attached files

Attached Image(s)

#1

13 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 3942
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/11 07:42:31 (permalink)
    +1 (1)
    Obviously the address in the at directive is a byte address.
    While your dump is showing word addresses (although only 14 Bits per word are available on this derivative).
     
    If you want to have your data starting with word address 0x1100, you have to locate it at byte address 0x2200.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    ric
    Super Member
    • Total Posts : 28324
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/11 13:38:41 (permalink)
    +1 (1)
    As above.
    PIC16F devices store 14 bits at every address, so hex files have to use two bytes per word location, so all addresses in the hex file are double the real physical address.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    A.Rajesh
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/05/07 18:41:55
    • Location: 0
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 18:11:20 (permalink)
    0
    Thanks for reply..I understand..
    can you explain..how the instructions are transfered from hex file to program memory..is it like 2 most significant bits of every 16 bits are unused/masked/go wasted?
    #4
    ric
    Super Member
    • Total Posts : 28324
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 18:15:20 (permalink)
    +1 (1)
    Unused. Those bits physically do not exist, there are only 14 real bits per word.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    A.Rajesh
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/05/07 18:41:55
    • Location: 0
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 18:47:37 (permalink)
    0
    so its is inefficient to use micros with 14 bit instruction for storage of lookup tables..
    shall I switch to pic18f as those use 16 bit wide instruction. in which case we can store full 2 bytes in flash and read 2 bytes without worrying about instruction length
    #6
    ric
    Super Member
    • Total Posts : 28324
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 18:53:00 (permalink)
    +1 (1)
    A.Rajesh
    so its is inefficient to use micros with 14 bit instruction for storage of lookup tables..

    That depends entirely upon what you want to store in those lookup tables.
    If it's only ASCII text, the assembler has support for saving two ASCII characters in each 14 bit location.
     

    shall I switch to pic18f as those use 16 bit wide instruction. in which case we can store full 2 bytes in flash and read 2 bytes without worrying about instruction length

    That's your choice. You have not revealed what sort of data you want to store, nor how you are accessing it.
    Memory is pretty cheap these days. You can often change to a PIC with double the FLASH for only a few cents more.
    So, it's often not worth the bother of trying to cram your data into the smallest space possible.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    A.Rajesh
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/05/07 18:41:55
    • Location: 0
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 19:32:16 (permalink)
    0
    I want to store bitmap data of different fonts..and bitmap data of some images..i want to transfer this data through hex file, not global const array.
    this data size may be close to 6 kb..I would read the prog memory in code using PMDATH and PMDATL registers.
    #8
    ric
    Super Member
    • Total Posts : 28324
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 19:46:52 (permalink)
    +1 (1)
    As you said, if it's purely binary data, your choices are.
    [1] Only use the lower 8 bits of each location, so 6 bits are wasted
    [2] Pack it into the 14 bit words, but there would be a lot of overhead unpacking it
    [3] Move to a PIC18F device.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    A.Rajesh
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/05/07 18:41:55
    • Location: 0
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 19:51:11 (permalink)
    0
    Thanks Ric for quick and useful replies
    #10
    ric
    Super Member
    • Total Posts : 28324
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 20:09:58 (permalink)
    +1 (1)
    Or spend 8 cents more, and swap your PIC16F1575 for a PIC16F18326, which has twice as much FLASH.
    (Although it is lacking the 16 bit PWM)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    A.Rajesh
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/05/07 18:41:55
    • Location: 0
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 20:41:00 (permalink)
    0
    yes..that option too..
    #12
    A.Rajesh
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2020/05/07 18:41:55
    • Location: 0
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 20:45:13 (permalink)
    0
    is there some setting that takes each byte from hex file and place it in each 14 bit instruction location..
    otherwise i have to explicitly fill 8 msb bits with 0's in hex file
    #13
    ric
    Super Member
    • Total Posts : 28324
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Adding loadable file in MPLAB project, but data is programmed at different address 2020/05/12 21:06:47 (permalink)
    +1 (1)
    If there was, it would be the hexmate.exe utility that comes with XC8 and MPLABX, but I don't think it can.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    Jump to:
    © 2020 APG vNext Commercial Version 4.5