memories

12
Memories

Upload: dori

Post on 25-Feb-2016

43 views

Category:

Documents


1 download

DESCRIPTION

Memories. 1. Flash Memory. Reprogrammable program Flash memory has the size of 8K x 16 bits (16KByte) by ATmega16. It has an endurance of at least 10,000 write/erase cycles. Program Counter (PC) is 13 bit wide, thus it is capable of addressing the entire Program memory locations. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Memories

Memories

Page 2: Memories

1. Flash Memory

• Reprogrammable program Flash memory has the size of 8K x 16 bits (16KByte) by ATmega16. It has an endurance of at least 10,000 write/erase cycles.

• Program Counter (PC) is 13 bit wide, thus it is capable of addressing the entire Program memory locations.

• Program Flash memory space is divided in two sections, the Boot program section and the Application program section.

ATmega16

Page 3: Memories

• Boot Memory Size is programmable thr’ fuses (128-1024 words(16bit)).

• Boot Memory allows downloading and uploading program code by the μC itself. This feature allows flexible application software updates using a Flash-resident Boot Loader program.

Page 4: Memories

2. SRAM

I/O Registers are control Registers for different functions like Communicat- ion functions, I/O Ports,….

ONLY I/O Registers $00 to $31 can be bit addressed:e.g. PORTA.3means bit 3 of PORT A(see Register Summary in ATmega16 manual)

Page 5: Memories

3. EEPROM• 512 byte having an endurance of at least 100,000

write/erase cycles.• Write access time ≈ 8.5ms.

• While read CPU halted for 4 clock cycles• While write CPU halted for 2 clock cycles

Page 6: Memories

• Address Register:

• Data Register:

• Control Register:

Read Enable

Write Enable

Ready Interrupt-Enablegenerates an interrupt when EEWE is cleared

Master Write Enable1=set EEWE within 4cycles to write0=no effect for setting EEWE

EEPROM I/O Registers

Page 7: Memories

C Compiler: CodeVisionAVR• Program variables can be global (accessible to all the functions in the

program) or local (accessible only inside the function they are declared).• If not specifically initialized, the global variables are automatically set to 0 at

program startup.

Page 8: Memories

EEWE must be 0

Address

Data

EEMWE=1

Set EEWE within 4 clock cycles

EEPROM WILL BE WRITEN IN

Write Sequence

Preventing EEPROM corruption:Periods of low VCC can cause this corruption. Remedy: enabling the internal Brown-out Detector (BOD).

Code

while(EECR & 0x02) //wait until EEWE=0#asm ("nop") //delayEEAR=2; //address=2

EEDR=5; //data=5

EECR.2=1; //Write logical one to EEMWE

EECR.1=1; //Start eeprom write by setting //EEWE

Page 9: Memories

Specifying the EEPROM Storage Address for Global Variables

• To store the integer variable "a“ in EEPROM at address 10h:

eeprom int a @0x10;

Page 10: Memories

Status Register

Bit 7 – I: Global Interrupt EnableBit 6 – T: Bit Copy StorageBit 5 – H: Half Carry FlagBit 4 – S: Sign Bit, S = N V⊕Bit 3 – V: Two’s Complement Overflow FlagBit 2 – N: Negative FlagBit 1 – Z: Zero FlagBit 0 – C: Carry Flag

Page 11: Memories

Program Counter

• The Program Counter keeps track of the location in flash program memory of the next instruction to be executed.

• When the uC is reset, the Program Counter resets to 000000.• Every instruction fetched causes the Program Counter to increment

by the number of bytes of this instruction.• Only by program jumps (conditional, unconditional and interrupts)

the contents of the Program Counter are changed.• Also by interrupts, the Program Counter content is stored on the

Stack(?) and a new program location is fetched, and on returning from interrupt the Program Counter regains its value.

Page 12: Memories

Assignment:

• The Atmega16 is used to control a lift in a 10 floor building.• Assume the average speed is 1m/s, and that the lift is moving on the

average 6 hours every day, and that the distance between floors is 3m.• The EEPROM stores the number of each floor it passes by, so that when the

supply is down and back again, the lift will recognize the floor it is at.– What other action can be done to let the controller recognize the floor?– What is the expected life of the controller?– Suggest a way for extending the life of the EEPROM.

• Homing• The lift moves 6x3600 m/day=7200

floor/day=7200write/erase cycles after 100,000/7200≈14 days the EEPROM will not accept data• Store location Cycling!