Lecture_05 - Reading & Writing EEPROM

Lecture_05 - Reading & Writing EEPROM - SEE215...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Faculty of Science and Technology Lecture 5 Reading & Writing EEPROM SEE215
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
EEPROM Electrically Eraseable Programmable Read Only Memory. Must be electrically erased before new data can be written The ATMega 128 has 4096 bytes of 8 bit EEPROM. The data is a contiguous block from $0000 - $0FFF EEPROM memory is used for storage of medium to long term data, which must remain when the processor looses power (non-volatile data). Eg passwords, configuration data, IP addresses, MAC addresses etc. The EEPROM can be erased & re-written at least 100,000 times.
Background image of page 2
EEPROM REGISTERS Access to the EEPROM for either read or write is done by accessing special EEPROM I/O registers. EEAR - EEPROM Address Register (16 bit) - comprised of two 8 bit registers EEARH & EEARL EEDR - EEPROM Data register (8 bit( - used for storing 8 bit data to be read & written EECR - EEPROM Control Register(8bit) - has control flags indicating status of EEPROM The read & write sequencesis not done by a single instruction(as can be done in Data RAM), but as a sequence of instructions. The reading & writing to EEPROM requires additional time and flags in the EECR are used to determine readiness of the EEPROM Ie. EERE - EEPROM Read Enable EEWE - EEPROM Write Enable EEMWE –EEPROM Master Write Enable See data sheet for register descriptions and EEPROM read & write sequences.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Solution sraight out of the box. ATMEL have provided suitable sequences in the ATMega128 data sheet for reading & writing EEPROM In both cases the routines are called after loading R18 & R17 with the EEPROM address which is to be written or read. IE. ldi R18,high(eeprom_address) ldi R17,low(eeprom_address) rcall EEPROM_read or rcall EEPROM_write
Background image of page 4
Reading EEPROM EEPROM_read: ; Check to see that we are ready to read sbic EECR,EEWE ;Wait for completion of previous write rjmp EEPROM_read ; in case we are still doing a write ; Set up address (r18:r17) in address register out EEARH, r18 out EEARL, r17 ; Do EEPROM read sbi EECR,EERE ; Start eeprom read by writing EERE in r16,EEDR ; Read data from data register ret
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Writing EEPROM EEPROM write code direct from AVR data sheet EEPROM_write: ; Check to see that we are ready to write sbic EECR,EEWE ; Wait for completion of previous write rjmp EEPROM_write ; Set up address (r18:r17) in address register out EEARH, r18 out EEARL, r17 ; Do EEPROM read out EEDR,r16 ; Write data (r16) to data register sbi EECR,EEMWE ; Write logical one to EEMWE sbi EECR,EEWE ;Start eeprom write by setting EEWE ret
Background image of page 6
Flash Erasure Counter The Flash memory has a finite number of times it can be erase (more then 10,000) and it would seem prudent for the bootloader to keep track of the number of previous erasures, which it does in EEPROM.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.
  • Three '09
  • Professor
  • Processor register, Elementary arithmetic, EEPROM, Atmel AVR, EEPROM Data register, Flash Erasure Counter

{[ snackBarMessage ]}

Page1 / 27

Lecture_05 - Reading & Writing EEPROM - SEE215...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online