• AVR Freaks

Hot!Filling Program Memory with 14-bit values.

Author
meits
Super Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2009/09/03 18:22:49
  • Location: 0
  • Status: offline
2020/07/12 00:50:03 (permalink)
0

Filling Program Memory with 14-bit values.

I'm using XC8 version 2.20 for the 16F15323 micro.  I have been placing known constants into program memory with the 2 methods:
1. using the --fill=0x2FFE,0x2FFF@0x500:0x501
2. const int myarray[2]__at(0x500) = {0x2FFE,0x2FFF}

 
Method 2 builds double the program memory space (4 address locations) because type "const int" is created as retlw [8-bit byte].
Method 1 builds the full 14-bit allowable value (2 address locations) into program memory at compile time.  My desired outcome.  Runtime 14-bit flash reading/writing works just fine as well.  But I am using a very large "fill" at compiling time that will be dynamic and not accessible from the XC8 Linker > Fill Flash Memory > Sequence > text box.
 
Is there a means to substitute a hex file for --fill?  Simply placing the file name does not work.
Or is there a directive/command/identifier in XC8 to make something similar to method 2 but store a 14-bit value into a single address instead of two 8-bit values into two addresses?
 
I took a snap shot of the difference.  Green is the desirable Method 1.  Red is Method 2.  Here the Opcode is important, the value returned from Microchip's FLASH_read library.

Attached Image(s)

#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27977
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Filling Program Memory with 14-bit values. 2020/07/12 01:52:32 (permalink)
    +2 (2)
    You can use DW directives inside inline assembly, or use the MPLABX "loadables" feature to add the hex file to your project.

    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!
    #2
    du00000001
    Just Some Member
    • Total Posts : 3841
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: online
    Re: Filling Program Memory with 14-bit values. 2020/07/12 02:07:40 (permalink)
    +1 (1)
    What a fine demonstration of the X-Y problem !
     
    Why not just write the values desired to the hex file (post-build) ?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #3
    meits
    Super Member
    • Total Posts : 62
    • Reward points : 0
    • Joined: 2009/09/03 18:22:49
    • Location: 0
    • Status: offline
    Re: Filling Program Memory with 14-bit values. 2020/07/12 12:58:12 (permalink)
    0
    I'll go with DW style for now.  Its working.  Only asm I wanted was the tried and proven unlock secquence, but no compiler is perfect.
     
    Thank you.
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5