[Icc-avr] Doubts using external memory variables

Guillermo Megía Palma g.megia at medicionytransporte.com
Tue Oct 30 00:34:53 PST 2007


Hello, 

Seeing that the discussion is about how and where the variables should be
declared and defined in C, I´d like to ask a question about how to declare
variables in external memory using imagecraft and ATMEGAs. What I´m doing is
something that I´m sure is not correct. I´m using the next statement in
main.c to define variables in external memory:

#pragma abs_address:INI_EXTERN_MEMORY //Address of the beginning of the
external memory
	type1 var_1;
	type2 var_2;
	type3 var_3;
	.
	.
	.
#pragma end_abs_address

The problem is that some of these variables are not used in main.c but I
need them in other modules. For example if I need var_1 in a module called
module1.c, I use the next declaration in module1.c:

extern type1 var_1;

I think this has no sense because I have defined in main.c variables that
I´m not going to use there, but I have not found a better solution.

First, I thought that other possibility was using the statement "#pragma
abs_address" in all the modules where I need to use variables in external
memory, but the problem is that I have to indicate the address where I want
to allocate these variables so I must count the number of bytes used in
variables previously allocated in external memory. I think this is something
really laborious.

I'd be really grateful if anyone can help me indicating a better way of
allocating variables in external memory. Something like a definition I could
use in every module where I need a variable in external memory.

Thanks in advance for your help.

Guillermo Megía



-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 5108 bytes
Desc: not available
Url : http://dragonsgate.net/pipermail/icc-avr/attachments/20071030/f37f217f/winmail.bin


More information about the Icc-avr mailing list