CodeVisionAVR and EEPROM handling

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is CodeVisionAVR protecting the EEPROM in any way, to prevent that the same value is written to the EEPROM over and over again?

I'm asking because I today use this method in my code:

if (eeprom_checksum != tmp_checksum)
    eeprom_checksum = tmp_checksum; 

(eeprom_checksum is an EEPROM variable (duh!), and tmp_checksum is an SRAM variable)

And I'm just wondering if it's even necessary, or if CodeVisionAVR is keeping track of this for me. Does anybody know?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Is CodeVisionAVR protecting the EEPROM in any way, to prevent that the same value is written to the EEPROM over and over again?

Yes it cleverly does this service for you. Note the CP and BREQ in this code it generates for an EEPROM access:

                 __EEPROMWRB1:
000068 b79f      	IN   R25,SREG
000069 94f8      	CLI
00006a bbae      	OUT  EEARL,R26
00006b bbbf      	OUT  EEARH,R27
00006c 9ae0      	SBI  EECR,EERE
00006d b38d      	IN   R24,EEDR
00006e 17e8      	CP   R30,R24
00006f f019      	BREQ __EEPROMWRB0
000070 bbed      	OUT  EEDR,R30
000071 9ae2      	SBI  EECR,EEMWE
000072 9ae1      	SBI  EECR,EEWE
                 __EEPROMWRB0:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great, that's what I hoped for. :) Thanks.