• AVR Freaks

Hot!MAP file: Pointer to be the address it is pointing to (instead of pointer address itself)?

Author
johndsd
Senior Member
  • Total Posts : 124
  • Reward points : 0
  • Joined: 2014/02/13 04:29:22
  • Location: 0
  • Status: offline
2015/10/05 05:44:22 (permalink)
0

MAP file: Pointer to be the address it is pointing to (instead of pointer address itself)?

When the map file is generated, is it possible that the memory address location can be made to be the address that the pointer is pointing to, rather than the address of the pointer itself ?
 
For example,
  • I have a pointer called *myPointer
  • the address of *myPointer is 0x35D8
  • the address *myPointer is pointing to is 0x363E
So the map file will show:
  • 0x35D8        myPointer
But I actually want it to show :
  • 0x363E        myPointer
 
I am using Simulink Coder to generate code from a Simulink model.  The input and output signals to the Simulink model are interfaced to variables within the platform software (hand written C code) using pointers which are externally declared in a source and header interface file.
 
For example, the source interface file will contain:
 
unit16 *myPointer=&analogueInput;
 
And the header interface file will contain:
 
extern unit16 *myPointer=&analogueInput;
 
The platform software will store data in the variable in 'analogueInput' and 'myPointer' will point to the address of the variable 'analogueInput'.
 
In the Simulink model, the signal 'myPointer' has the option "Signal name must resolve to Simulink signal object" selected and the storage class for the Simulink signal object is set to "ImportedExternPointer".  This means that the signal 'myPointer' in the Simulink model is declared externally and will not be declared by the code that it generates.  Instead it will use the declarations made externally in the interface source and header files.
 
I am also using Vector CANape (a calibration tool to log signals and change parameters via CAN).  This is where the problem occurs, because it is not possible to log the input and output signals in the Simulink model.  This is because the address locations of the input and output signals are the address of the pointer, not the address of the variable it is pointing to.  Hence the reason for my question.
 
I am using a dsPIC33EP256MU810 processor with MPLAB X and the XC16 compiler.
#1

5 Replies Related Threads

    Aussie Susan
    Super Member
    • Total Posts : 3636
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: MAP file: Pointer to be the address it is pointing to (instead of pointer address itse 2015/10/05 18:03:52 (permalink)
    0
    That does not really make sense to me in the context of a map file which shows where, in memory, the variables are located.
    A pointer, by its very nature, will stay in the same location but can *point* to (just about) any other location in memory.
    While you are setting the pointer location at compile-time, you are not telling the compiler that it is a 'const' reference (and therefore cannot be changed) so the compiler/linker have can only assume that the pointer itself is in a fixed location but what it is pointing to can change at any time.
    Susan
    #2
    johndsd
    Senior Member
    • Total Posts : 124
    • Reward points : 0
    • Joined: 2014/02/13 04:29:22
    • Location: 0
    • Status: offline
    Re: MAP file: Pointer to be the address it is pointing to (instead of pointer address itse 2015/10/06 02:28:07 (permalink)
    0
    The calibration tool Vector CANape uses a protocol called CCP (CAN Calibration Protocol).
     
    CANape requires a database file which contains the names of signals that can be logged or calibration parameters that can be changed, along with the datatype, its scaling and most importantly the address of the signal or calibration parameter.  Using the example in my original post, the a2l file would contain:
     
    /begin MEASUREMENT
    /* Name */ myPointer
    /* Long identifier */ "Analogue input"
    /* Data type */ UWORD
    /* Conversion method */ uint16
    /* Resolution (Not used) */ 0
    /* Accuracy (Not used) */ 0
    /* Lower limit */ 0
    /* Upper limit */ 65535
    ECU_ADDRESS 0x35D8
    /end MEASUREMENT
     
    Note that the ECU_ADDRESS is the address of the pointer, not the address it is pointing to.  So if I tried to log this signal in CANape it would display the value of the address it is pointing to (i.e. 0x363E) rather than the value for the variable 'analogueInput' which is in address 0x363E.
     
    The a2l file is generated using the MAP file - it extracts the address locations for the all the signals and calibration parameters.
     
    If the MAP file contained the address that the pointer is pointing to (instead of the pointer address itself), then the address in the a2l file would be correct and I would be able to log the signal 'analogueInput'.  For example:
     
    /begin MEASUREMENT
    /* Name */ myPointer
    /* Long identifier */ "Analogue input"
    /* Data type */ UWORD
    /* Conversion method */ uint16
    /* Resolution (Not used) */ 0
    /* Accuracy (Not used) */ 0
    /* Lower limit */ 0
    /* Upper limit */ 65535
    ECU_ADDRESS 0x363E
    /end MEASUREMENT
     
     
     
     
     
     
    post edited by johndsd - 2015/10/06 02:31:25
    #3
    jack@kksound
    code tags!
    • Total Posts : 3220
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: MAP file: Pointer to be the address it is pointing to (instead of pointer address itse 2015/10/06 14:25:22 (permalink)
    +1 (1)
    If the address is fixed then a pointer is not needed, if the address is to be fixed at the time the MAP file is generated then it must be set/known at compile time and the pointer is not needed, IMHO.
    #4
    DuaneH
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2009/10/15 11:49:22
    • Location: Sandy, UT
    • Status: offline
    Re: MAP file: Pointer to be the address it is pointing to (instead of pointer address itse 2019/11/14 13:13:01 (permalink)
    0
    To use your example, MyPointer will have a RAM address assigned to it by the linker (tied to a value you specify, if you so decide), and AnalogInput will also have an address assigned to it.  So, you really do have the value you want in the map file, it's just the address of AnalogInput (not MyPointer).  You can have your debugger watch window show the value of *MyPointer, but there is no way the linker can know (and put into the map file) what value you are going to assign to the pointer once your program runs. 
    If the pointer is always going to point to the same location, then you don't need a pointer at all- just reference the value directly in your program.  A pointer which never changes is a waste of resources, and bloats your program with unnecessary de-referencing with no compensating benefit.

    duaneh
    #5
    crosland
    Super Member
    • Total Posts : 1695
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: MAP file: Pointer to be the address it is pointing to (instead of pointer address itse 2019/11/14 14:02:52 (permalink)
    +1 (1)
    I think the OP has probably moved on in the intervening 4 years.
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5