Eric Myerson

Global structure variable elements have different addresses

Discussion created by Eric Myerson on Oct 7, 2011
Latest reply on Oct 14, 2011 by Eric Myerson

- Which CPU are you targeting:                                    MCF52258
- Which version of CodeWarrior are you using?      10.0 and 10.1 (we see problem on both)

 

Hi!  We are seeing some unexpected global variable behavior:

In one file the code writes a value into an element of a global structure, but when the code reads the same value in another file it isn't what was written. This is because it's reading (the same structure element) from a different memory location. For example: When the variable 'tva.options.probe_type' is accessed in the probe.c function 'probe_init()' - the address shown by the debugger is 0x20004f69; the address shown in the assembly code window, and what is changed in the memory is 0x20004eb4. This means the function 'probe_init()’ accesses and changes the wrong variable.

Does anyone have any ideas on how we can get to the bottom of this behavior?

Outcomes