EEPROM in microcontrollers AVR Atmega

EEPROM, Atmega

Microcontrollers AVR Atmega48 / 88/168/328 contain the EEPROM memory of 256/512/512 / 1K bytes , respectively. EEPROM in AVR microcontrollers can support up to 100,000 write cycles. Access to non-volatile memory is carried out through three types of registers:

  • EEARH, EEARL - registers the addressing of memory cells. In case Atmega48 EEARH absent, because in this type of microcontroller 256 is present in all memory cells. EEARH responsible for the high byte of memory address, EEARL for the least significant byte;
  • EEDR - register for writing and reading data;
  • EECR - register control, this register is setting the actions to be performed with the memory.

A detailed description of EEPROM registers

EEARH and EEARL - registers EEPROM cell address

Bits from 9 to 15 are reserved and always read with the value zero.

Bits from 0 to 8 are used to indicate non EEPROM memory cell to which the treatment will be.

EEDR - EEPROM data register

Bits from 2 to 7 - which is written bits in the information to be recorded in EEPROM or read from it.

Bits from 6 to 7 - bits are reserved

Bits from 4 to 5 - EEPM1 and EEPM0 - EEPROM used to set the operation mode.

  • EEPM1 = 0, EEPM0 = 0 - An atomic operation is the removal and recording of data (duration 3.4 ms)
  • EEPM1 = 0, EEPM0 = 1 - Only the deletion of data (duration 1.8 ms)
  • EEPM1 = 1, EEPM0 = 0 - Data Entry Only (duration 1.8 ms)
  • EEPM1 = 1, EEPM0 = 1 - Reserved for future use

Bit 3 - EERIE - this bit is used to enable interrupts, in case if you are allowed to interrupt the firmware of your controller.

Bit 2 - EEMPE - protection bit of the recording. Delays process of writing data to the EEPROM on the four cycles to EEPROM had time to prepare for the recording of data.

Bit 1 - EEPE - write bit start, exhibited to start recording, cleared to zero in hardware, at a time when the recording is completed. Therefore, it may be used to control the data recording process in EEPROM.

Bit 0 - WERE - bit start reading. exhibit for reading from EEPROM launch.

Read and write operations

Atmega EEPROM in a very slow interface, which requires up to 4 ms to perform write operations. Therefore it is very important to check that the previous write operation is completed successfully.

;======= EEPROM write procedure in ======================================================
 EEWrite: 
    sbic EECR,EEPE          ; We expect that over the previous write operation.
    rjmp EEWrite            ; Out of the loop as long as the flag is cleared EEPE
    cli                     ; Then we put out a ban on interrupting.
    out EEARL,r16           ; Set the address of the cell to which we refer
    out EEDR,r17            ; as well as write data to the register information,
                            ; that will keep
    sbi EECR,EEMPE          ; set protection on record
    sbi EECR,EEPE           ; set the write flag
    sei                     ; then allow interrupt
    ret                     ; and return from the subroutine.
 ;======= The procedure of reading from the EEPROM ======================================
 EERead: 
    sbic EECR,EEPE          ; We expect that over the previous write operation. 
    rjmp EERead 
    out  EEARL, r16         ; Set the address of the cell to which we refer
    sbi  EECR,EERE          ; Start reading setting for reading the flag
    in   r17, EEDR          ; Return the reading result in the desired register
    ret 
 ;=======================================================================================

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.
Support the author Donate

Comments

Only authorized users can post comments.
Please, Log in or Sign up
Looking for a Job?
25,000.00 руб. - 30,000.00 руб.
Разработчик Qt/C++
Barnaul, Altai Krai, Russia

For registered users on the site there is a minimum amount of advertising

s
Sept. 18, 2019, 5:19 p.m.
sanyalitv

C++ - Test 002. Constants

  • Result:33points,
  • Rating points-10
s
Sept. 18, 2019, 5:12 p.m.
sanyalitv

C++ - Test 001. The first program and data types

  • Result:80points,
  • Rating points4
d
Sept. 18, 2019, 7:34 a.m.
dbuzin

C++ - Test 001. The first program and data types

  • Result:33points,
  • Rating points-10
Last comments
M
Sept. 20, 2019, 11:25 a.m.
Mark

вызываю метод get у m_downloader в другом методе и приложение начинает вылетать. В чем ошибка?
M
Sept. 19, 2019, 5:45 a.m.
Mark

А вот как выгрузить файл на сервер по http протоколу? Допустим на regRu. И как получить путь файла, которой отображается в файловом менеджере regRu, чтобы загрузить его.
Sept. 17, 2019, 6:07 a.m.
Misha Lebedev

Кстати интересные темы нашёл тут https://emacsway.github.io/ru/django-framework/#django-models Может что полезного тоже Евгений найдёте
Sept. 17, 2019, 4:50 a.m.
Misha Lebedev

Доброго времени суток. Спасибо за хороший ответ, У меня ситуация така что в галлереи будет несколько миллионов фотографий с фильтрами и тегами , и я опасаюсь за производительност . Это ос…
Sept. 17, 2019, 3:23 a.m.
Evgenij Legotskoj

Добрый день. Да, я тоже читал ту статью в своё время и согласен с тем, что внешние ключи гораздо лучше, чем GenericForeignKey. Выборки в ряде случае работают быстрее. Но лично мне про…
Now discuss on the forum
Sept. 20, 2019, 4:56 a.m.
Pavel K.

Привет , подскажите кто-нибудь , как сделать драг н дроп , не нарушая при этом логику работы зума? import QtQuick 2.6 import QtGraphicalEffects 1.0 Page { id:win property string fi…
Sept. 19, 2019, 8:03 a.m.
Mihailll

Скопировал базу в папку пользователей и тогда получилось записывать в нее
Sept. 19, 2019, 5:32 a.m.
Mihailll

Но мне же нужно еще получить этот id и вернуть его пользователю, а при таком запросе ничего не вернется.
M
Sept. 18, 2019, 5:35 p.m.
Mark

Понятно Тогда можно ли достать только параметры файла? Например только дату его изменения
p
Sept. 17, 2019, 5:02 a.m.
pstMem

Да, действительно нужно дебажить, по другому не словить исключение. Уже решил проблему, был выход за предел массива, не правильные входные данные, так что всегда проверяйте размер массива.
EVILEG
About
Services
© EVILEG 2015-2019
Recommend hosting TIMEWEB