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

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

[avr-gcc-list] eeprom problem


From: Marcus Overhagen
Subject: [avr-gcc-list] eeprom problem
Date: Sun, 27 May 2001 03:17:30 -0700

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
 



reply via email to

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