On Tue, Dec 13, 2011 at 6:03 AM, JMGross <[email protected]> wrote:
> ----- Ursprüngliche Nachricht -----
> Von: Peter Bigot
> Gesendet am: 12 Dez 2011 21:39:15
>
> On Mon, Dec 12, 2011 at 2:31 PM, Timothy Logan <[email protected]>
> wrote:
>>> I am porting some code from IAR which involves me having to place a few
>>> different structures in very specific addresses in the MSP430 memory.
>
>> You can use asm statements, as are done with the peripheral register
>> declarations. Something like:
>> volatile unsigned int specialdata __asm__("0x1320");
>> will force the definition of specialdata to be placed at address 0x1320.
>
> That's the obvious way.
> However, it must be used with care.
> The variable locations are put as direct addresses into the
> compiler-generated assembly output.
> The linker won't see them or know of them.
Which is why the real peripheral register declarations use:
volatile unsigned int P1OUT __asm__("__P1OUT");
where __P1OUT is a symbolic constant defined at final link time from
the MCU-specific periph.x file. The same thing can be done in this
case so ensure all modules get the same address. The original request
was for a simple way that didn't muck with linker scripts, but if the
potential for inconsistency is a concern the symbol value can also be
provided on the linker command line; see the msp430-ld man page.
Peter
> So if two independent compilaiton units (C files)
> Use their own "superstatic variable" and it happens
> to be placed on the same location, you won't get
> an error or even a warning. And the two code parts
> will mess with each others storage then.
>
> Especially dangerous when using libraries, where
> the particular code is not checked/adjusted for every project.
> (so it could be noticed)
>
> JMGross
>
> ------------------------------------------------------------------------------
> Systems Optimization Self Assessment
> Improve efficiency and utilization of IT resources. Drive out cost and
> improve service delivery. Take 5 minutes to use this Systems Optimization
> Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/
> _______________________________________________
> Mspgcc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
------------------------------------------------------------------------------
Systems Optimization Self Assessment
Improve efficiency and utilization of IT resources. Drive out cost and
improve service delivery. Take 5 minutes to use this Systems Optimization
Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users