News:

SMF for DIYStompboxes.com!

Main Menu

AVR EEPROM programming

Started by bioroids, December 13, 2007, 02:13:03 PM

Previous topic - Next topic

bioroids

Hi guys!

I'm following the procedure that is in the datasheet, but the bytes don't seem to stuck to the EEPROM  :icon_evil:

What do you think of this:

// Write to EEPROM
EEDR = 1;            // Data to be written
EEAR = 0x7F;         // Address to be written to
EECR |= 0x01 << EEMWE;   // Enable Master Write
EECR |= 0x01 << EEWE;   // Do write
while (EECR & (0x01<<EEWE)) {
    // Wait for write to complete
}


By the way, this is an ATTiny26. It's driving me mad! Still working on the PWM Phaser, and the ATTiny13 was too small for it
   
Any help is greatly appreciated

Miguel
Eramos tan pobres!

The Tone God

Give me a few and I'll compare what you have to my EEPROM library.

Andrew

bioroids

Problem solved!

It turns out that I wasn't using optimization, so the code I posted above, when compiled, required more than 4 cycles, and that is restriction for the write to be executed. The optimization solved that (and also reduced my code from 2046 bytes to about 1600 :icon_exclaim:).

Just for the record, I also had to declare some global variables as volatile, because the optimizer loaded them in registers and when the value was changed outside the main function, the change was lost.

Everything is back on track! Thanks Tone God for introducing me to this little and powerfull monsters

Regards

Miguel
Eramos tan pobres!