SV: [Icc-avr] Doubts using external memory variables

Steven Lose sl at ecpower.dk
Tue Oct 30 01:25:49 PST 2007


Hi.

Do you mean that you have external memory, but have not told the compiler about it?
If so, then you must control it yourself by enabling external memory bus and then memory map your variables

Like:
#define LCDBASEADR 0x8000

#define LCDDATA	   (*(volatile char *)(LCDBASEADR + 0x00))
#define LCDCOMMAND (*(volatile char *)(LCDBASEADR + 0x01))

If you have told the compiler about the external mem, then just declare the variables in top of your module, then they are put in external mem.
Look at the map file.

If you need fixed adr. In external mem, and have told the compiler about the external memory, then use the define as above and then you need to let the compiler know that this mem area is used. In the example area 0x8000 to 0x8001
The syntax for this I don't remember but that subject has been on this list before, so you should be able to find it.
It should be put in the Project/options menu if I remember correct.


Med venlig hilsen / Best regards / mit freundlichen Grüßen

EC POWER A/S

Steven Lose

Software Ingeniør

Tlf.: +45 87434100

Direkte tlf. +45 58286608

Email: sl at ecpower.dk <blocked::mailto:bsl at ecpower.dk> 

www.ecpower.dk


_____________________________________________
Fra: icc-avr-bounces at imagecraft.com [mailto:icc-avr-bounces at imagecraft.com] På vegne af Guillermo Megía Palma
Sendt: 30. oktober 2007 09:35
Til: icc-avr at imagecraft.com
Emne: [Icc-avr] Doubts using external memory variables

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


 <<Fil: ATT43050.txt >> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20071030/ea2dcc21/attachment-0001.html


More information about the Icc-avr mailing list