• AVR Freaks

Hot!Array addressing allocated in program memory

Author
Andrew_miksys
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2008/01/24 02:47:48
  • Location: 0
  • Status: offline
2020/02/21 08:28:48 (permalink)
0

Array addressing allocated in program memory

Hi, I'll start with the code
(first module html.c):
static ROM unsigned char MPFS_0000[] = 
{
 0x44, 0x56,........
}
static ROM unsigned char MPFS_0001[] =
{
 0x23, 0x91,........
}
.........
typedef struct
{
 unsigned char Flags;
 ROM unsigned char* Address;
 unsigned char Name[12];
} FAT_TABLE_ENTRY;

ROM FAT_TABLE_ENTRY MPFS_Start[] =
{
 { 0x00, MPFS_0000, 'A', 'B', 'O', 'R', 'T', '.', 'C', 'G', 'I', ' ', ' ', ' ' },
 { 0x00, MPFS_0001, 'C', 'O', 'N', 'F', 'I', 'G', '.', 'C', 'G', 'I', ' ', ' ' },
 { 0x00, MPFS_0002, 'E', 'M', 'A', 'I', 'L', '.', 'C', 'G', 'I', ' ', ' ', ' ' },
......
}

 
and in main.c module:
rom byte * FAT;

FAT = (rom byte*)&MPFS_Start;

 
Everything was fine when MPFS_Start was allocated below address 0x10000.
Unfortunately, at some build, the array was placed at 0x1066A and soft stopped working properly.
In Disassembly Listing I found:
197: FAT = (rom byte*)&MPFS_Start;
 1C322 0108 MOVLB 0x8
 1C324 0E0C MOVLW 0x6A
 1C326 6F97 MOVWF 0x97, BANKED
 1C328 0E00 MOVLW 0x06
 1C32A 6F98 MOVWF 0x98, BANKED
 1C32C 6B99 CLRF 0x99, BANKED

Is there a wrong declaration or some other mistake???
post edited by Andrew_miksys - 2020/02/21 12:27:16
#1

10 Replies Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5970
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 09:24:37 (permalink)
    +1 (1)
    Looks like a bug in the compiler. It sets 0x66a instead of 0x1066a. I would open a support ticket with Microchip.
    #2
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11681
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 09:31:08 (permalink)
    0
    Why are you casting?  What PIC are you using?  What memory model are you using?
     
     
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 18424
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Array addressing allocated in program memory 2020/02/21 10:32:08 (permalink)
    +1 (1)
    NorthGuy
    Looks like a bug in the compiler. It sets 0x66a instead of 0x1066a. I would open a support ticket with Microchip.


    You would Open a Support Ticket about the C18 Compiler?  That Ship has sailed.
    #4
    1and0
    Access is Denied
    • Total Posts : 10588
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 10:33:55 (permalink)
    +1 (1)
    Why not use XC8?
    #5
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11681
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 10:39:22 (permalink)
    +1 (1)
    1and0
    Why not use XC8?

     
    I'm guessing the OP is working with the ancient TCP/IP stack which I think only supported C18.
     
    I'm also guessing he's using the small code model which uses 16-bit "rom" pointers which why his pointer gets truncated in the cast.
    #6
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11681
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 10:50:47 (permalink)
    +1 (1)
    That Ship has sailed.

     
    But unfortunately it hasn't sunk yet.
    #7
    Andrew_miksys
    New Member
    • Total Posts : 26
    • Reward points : 0
    • Joined: 2008/01/24 02:47:48
    • Location: 0
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 12:39:33 (permalink)
    0
    18F67j60
    Build Options -> MPLAB C18 -> Memory Model:
    Code Model: Large Code Model (>64K bytes)
     
    I forced to put this array below address 0x10000 and it's ok.
    Of course this is only temporary solution
    #8
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11681
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 12:45:32 (permalink)
    +1 (1)
    Again, why are you casting?  If you have to cast, you should be using "far rom", not just "rom".
    #9
    Andrew_miksys
    New Member
    • Total Posts : 26
    • Reward points : 0
    • Joined: 2008/01/24 02:47:48
    • Location: 0
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 13:45:31 (permalink)
    0
    Where should I use "far rom"?
     
    #10
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11681
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Array addressing allocated in program memory 2020/02/21 14:01:47 (permalink)
    +1 (1)
    In the cast that you still haven't explained.
    #11
    Jump to:
    © 2020 APG vNext Commercial Version 4.5