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 AVR

Status
Not open for further replies.

luben111

Advanced Member level 1
Joined
Mar 2, 2002
Messages
489
Helped
111
Reputation
223
Reaction score
107
Trophy points
1,323
Location
UK
Activity points
3,924
Hello,

I can't realize how to define persistent variables (that will be not reset after power up) in IAR compiler for AVR.

What I found in the manual is to use __no_init keyword before the definition of variable.

So...
__no_init char my_var;

should be declared like persistent variable.

When I compile the project I don't get errors, but when I link it I got the following:

Error[e16]: Segment NEAR_N (size: 0x1 align: 0) is too long for segment definition. At least 0x1 more bytes needed. The problem occurred while processing the segment placement command "-Z(DATA)NEAR_N=_..X_EXT_NV_BASE-_..X_EXT_NV_END", where at the moment of placement the available memory ranges were "-none-"


Please, can you explain what I'm doing wrong? I will be very thankful for any help, because I need badly to finish one project where I hav eto define persistent variable.

best regards
Luben
 

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

Hi Luben,

I faced the same problems with IAR for AVR.

I think it wants to place _no_init variables into flash or eeprom and as it does not know where to put it you get this error??

I used __eeprom which worked for me but places the variable into EEPROM you could also use __flash to place it into flash memory.

There is no persistent keyword at IAR no idea why.

Hope this helps and best regards
 

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

Hello,

Thank you for your reply.

Yes, maybe if I put the variable into EEPROM it will work, but unfortunately this is not exactly what i want.

I just want after reset occures to understand is it "hot" reset, I mean - when you bring low RESET line the chip goes to reset, but doesn't change the contents of variables. So, if I put into some variable some value (for example 0xAA) after the reset if I get read the same value that means I had "hot reset". This allows to do some opreations with reset.

But if I can't get other approach I'll do in this way.

Best regards
Luben
 

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

Yes I know what you mean, I am using this "trick" myself using Keil and Hi-Tech compilers but could not find a way in IAR except __eeprom or __flash.

No idea why IAR does not support the persistant keyword :-(

best regards and good luck for your project
 

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

Dear All,

I had the same problem, but I manage to solve it:

You can use the Keyword __no_init, but the memory model needs to be Tiny bot Small.

I took me ages to find this. Unfortunately it is hard to find good advance documentation on IAR AVR.

Samuel
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top