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

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

Re: [avr-gcc-list] eeprom problem & compile problems.


From: Larry Barello
Subject: Re: [avr-gcc-list] eeprom problem & compile problems.
Date: Sat, 26 May 2001 21:58:26 -0700

Marcus: look at the file "eeprom.h" for hints on how to do what you want to
do.
By the time you do the assignment you are no longer dealing with variables
in the eeprom segment.  You are simply assigning values to SRAM that
happens to have the same address of your eeprom variables.

GCC doesn't really handle various memory spaces like ICC or IAR or CV does.
You can tell it to put stuff into various segments, but accessing FLASH or
EEPROM takes special routines that are handled by macros and inline
assembly in the avr version of GCC.  The header file I mentioned will give
you the details.

For your bit test problems: the AVR instruction set has all sorts of
limitations of which registers are usable with which instructions.  For
example the immediate instructions only work on R16-R31.  All the bit
manipulation instructions only operate on the lower 32 I/O addresses.  Etc.

Know the hardware!

Cheers!
Larry Barello
http://www.barello.net

----- Original Message -----
From: "Marcus Overhagen" <address@hidden>
To: <address@hidden>
Sent: Sunday, May 27, 2001 3:17 AM
Subject: [avr-gcc-list] eeprom problem


> I need to remember a few variables during power loss, but it doesn't
work.
> The calibration does work, but saving the variables to eeprom
> and using them as initial values does not produce the correct result.
>
> I'm using the Windows AVR-GCC compiler from avrfreaks.net
>
> What is wrong here? The device is a AT90S2313 running at 10 MHz.
>
> typedef unsigned short uint16;
>
> uint16 eeprom_dummy1 __attribute__ ((section (".eeprom")));
> uint16 eeprom_min __attribute__ ((section (".eeprom")));
> uint16 eeprom_neutral_min __attribute__ ((section (".eeprom")));
> uint16 eeprom_neutral_max __attribute__ ((section (".eeprom")));
> uint16 eeprom_max __attribute__ ((section (".eeprom")));
> uint16 eeprom_dummy2 __attribute__ ((section (".eeprom")));
>
> volatile uint16 input_min;
> volatile uint16 input_neutral_min;
> volatile uint16 input_neutral_max;
> volatile uint16 input_max;
> volatile uint16 input_current;
>
>
> void calibration(void)
> {
> //do calibration here
>
> cli(); //disable interrupts
>
> eeprom_min = input_min;
> eeprom_neutral_min = input_neutral_min;
> eeprom_neutral_max = input_neutral_max;
> eeprom_max = input_max;
>
> sei(); //enable interrupts
> }
>
>
> int main(void)
> {
> input_min = eeprom_min;
> input_neutral_min = eeprom_neutral_min;
> input_neutral_max = eeprom_neutral_max;
> input_max = eeprom_max;
>
>   //program starts here
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
>




reply via email to

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