Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to define persistent variables in IAR compiler for ARM

Status
Not open for further replies.

morteza_rabi

Newbie level 2
Joined
Jun 20, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
iran
Activity points
1,302
Hi, everyone!
I'm using AT91SAM7X256 . I can't realize how to define persistent variables (that will be not reset after power up) in IAR compiler for ARM. I've gone through the IAR Compiler refrence guide which says that __no_init variables are not initialized when the system starts. Does this necessarily imply that these variables are not destroyed when the system shuts down? I've read in a blog that this __no_init directive only prevents initialization of these variables and it can not make sure that these variables will retain their value when the system shuts down.
Actually, I need to store certain variables that are required to retain their value even when the system in not powerd ON.
The target is to save and keep variables when the device is OFF.

Thanx

Regards

M. Rabi
 

Do you know the difference between volatile and non-volatile memory? e.g. RAM is volatile, loses information when power is gone. EEPROM is non-volatile and would be the kind of memory that fits your needs. You can you an EEPROM connected to the SPI bus or TWI or a memory mapped device. If memory mapped, YOU assign a memory range, activate a chip select and the compiler will create what you tell him to.
Is it possible that this is your first embedded project?
hth, Bob
 
no it's not my first embedded project, I know volatile and Non-volatile memory, and I'm sure if i use an EEPROM, it fits my work. But i 'm using AT91SAM7X256, it has 256Kbyte Flash Memory that it's non-volatile memory. i want use this memory instead of an external EEPROM, but i have problem with Compiler (IAR) , i don't know how i can declare a variable that Linker of compiler locates it in Flash memory.(it locates all of my variables in RAM memory).
Thanx
 

Re: How to define persistent variables in IAR compiler for A

Does IAR have something like ORG instruction or a similar way?
I have never used IAR before, I m just thinking with you.
Another thing you should consider. Is this Flash can be read and written on byte basis?
 

IAR C Compiler Manuals:
http://www.iar.com/website1/1.0.1.0/78/1/

Atmel AT91SAM7X256 manual:
http://www.atmel.com/dyn/resources/prod_documents/doc6120.pdf

Added after 13 minutes:

You need to supply us details about the target system. Are you using an Atmel Eval board, 3rd party board, or a project with the chip? Does the board have any EEPROM, battery-backedup RAM, or any other memory chips?

The FLASH in the Atmel ARM chip can save live variables. A person might save some settings type parameters, but you sure the heck don't want to write too often to the FLASH, otherwise you will "burn out a sector".

If prices doesn't matter, then you might want to add a EverSpin MRAM chip via SPI. **broken link removed** Otherwise if price is important, then add a serial EEPROM via SPI.

Still with SPI, you won't be able to talk to it like normal RAM, but instead you will be able to dump settings or snaps shots of data to it, then on power-up you would load those settings.

Everything starts with the hardware...if you don't have the correct type of memory or battery-backup...then it doesn't matter what compiler you are using because it can't fix the problem.
 

Re: How to define persistent variables in IAR compiler for A

Hi

You need to define the variable as NOINIT using the __noinit macro in front of the variable

Also the variable must lay out side of any function or procedure(defined as Global)

All the best

Bobi


The microcontroller specialist
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top