avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: [avr-gcc-list] Query regarding hard located variables


From: Scott Finneran
Subject: Re: Fwd: [avr-gcc-list] Query regarding hard located variables
Date: Tue, 08 Jan 2002 09:17:22 +1100

Hello Torsten,

Thankyou for your suggestion, unfortunately it does not answer my
question. What you have suggested will work but has problems. 

Perhaps I did not explain my problem well enough. I have a hardware
register which is in data memory space. It overlays a single memory
location. It is not at the begining or end of memory, so I cannot simply
change the MEMORY section of linker script to begin after it or stop
just before it (I would lose approx 20% of my RAM doing this). Accessing
the location is not a problem, it is a simple pointer operation (as you
have indicated). However, as the register lives in the middle of my data
space (ie it overlays one location of my external SRAM device), it is
quite likely that the linker will assign the memory address to an
unrelated variable. As you can imagine, this will cause all kinds of
mysterious behaviour of the system when I modify this variable.

What I would like to do is either:
A) Assign a specific variable to this memory location (which I can then
use to access the register).

or

B) Reserve the memory location so that the linker does not use it. I can
then safely access it with a pointer as you have suggested.

Does anyone know how to do either of these things?

Thanks in advance,

Scott


Torsten Mohr wrote:
> 
> Hi,
> 
> normally this is not the way to declare HW registers
> at fixed addresses, i know it ike this:
> 
> #define HW_REGISTER    (*((char*)0xff1234))
> 
> Now you can access HW_REGISTER and read/write from/to it.
> 
> Take the address of the register, cast it to a pointer to
> a char (if the register size is 8 bit) and dereference it
> with a "*".
> 
> Regards,
> Torsten.
> 
> ----------  Weitergeleitete Nachricht  ----------
> 
> Subject: [avr-gcc-list] Query regarding hard located variables
> Date: Mon, 07 Jan 2002 13:33:05 +1100
> From: Scott Finneran <address@hidden>
> To: avr-gcc-list <address@hidden>
> 
> Hello All,
> 
> I would have thought that the following would be a more commonly asked
> (and therefore answered) question. I can only assume that I am searching
> for the info in the wrong place or using the wrong keywords. If so, then
> I apologise in advance.
> 
> I would like to know how to hard locate a variable using gcc and/or the
> gnu linker. The hardware that I am using has a number of memory mapped
> hardware registers. Obviously I would like to avoid having the linker
> drop variables into memory addresses where these registers live. It
> would also be nice to be able have variables (of my choosing) be located
> at these addresses. Of course the latter can be easily achieved with a
> pointer. Many commercial embedded compilers provide a compiler specific
> directive such as:
> eg int reg1 _at(0x4000);
> 
> Others simply allow you to specify the location of specific variables in
> linker scripts.
> 
> I have seen many websites and articles (eg from embedded.com) talk about
> doing this. Many more say that it is possible. None of them (that I have
> found) say how, or even better give an example.
> 
> Can anyone point me to some info or alternatively show me how this is
> done?
> 
> Kind Regards,
> 
> Scott Finneran
> avr-gcc-list at http://avr1.org
> 
> -------------------------------------------------------
> avr-gcc-list at http://avr1.org
avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]