0% found this document useful (0 votes)
14 views11 pages

L07-AVR Program Counter and ROM Space

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views11 pages

L07-AVR Program Counter and ROM Space

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

CS-336: Embedded Systems

AVR Microcontroller:
Program Counter
and
Program ROM Space
Slight modification of slides shared by Dr. Rehan Ahmed

Instructor: Asra Abid Siddiqui [[email protected]]


Program Counter (PC)
• Program Counter (PC)
– The most important register in the AVR microcontroller
 Points to the address of the next instruction to be executed
 Is incremented automatically to point to the next instruction

– The wider the PC is, the more memory locations it can


access
 For example:
– 14-bit PC = 16K locations
– 15-bit PC = 32K locations
– 16-bit PC = 64K locations

2
AVR On-Chip ROM Size and Address Space
• In AVR Microcontroller each Flash Memory location is
2-bytes wide
– Correspondingly the flash is organized as shown in the last
column of the table below
– This arrangement will also change the address range
 see the second last column in the table below
– Example in next slide
– Address 0 is always the first ROM address

3
ROM Memory Address Range

Total ROM Size = 2KB Total ROM Size = Total ROM Size =
16KB 64KB

Notice the memory organization and the start and end


address
4
AVR PC
• Program counter in the AVR family can be a maximum of
22-bits
– Correspondingly, no member of the AVR family can access
more than 4M words [do the maths!]

• The ATmega16A Program Counter (PC) is 13 bits wide,


– thus addressing the 8K program memory locations.

5
Wake-Up Address
• At what address does the CPU wake-up when power is
applied?
– AVR microcontroller wakes up at memory address 0000
 PC (program counter) has the value of 00000 in it
– It expects the first opcode must be burned into memory location
$00000
– Achieve this by using the .ORG statement

6
Endianness
• Endianness is the sequential order in which bytes are
arranged into larger numerical values when stored in
memory:
– Little Endian
– Big Endian

7
AVR Endianness

Loading the value: 12345678h

• AVR Microcontrollers
store and retrieve data
from memory using little-
endian order (low to high).

• The least significant


byte is stored at the
first memory address
allocated for the data.

8
Flash memory and PC register [ATmega16a]

00 E205
LDI R16, 0x25 01 E314
LDI R17, $34 02 E321
E321
LDI R18, 0x31 03 0F01
0F01
ADD R16, R17
04 0F02
0F02
ADD R16, R18
LDI R17, 11 05 E01B
16-bit
E01B
ADD R16, R17 06 0F01
0F01
STS SUM, R16 07 9300
HERE:JMP HERE 9300
08 0300
0300 RAM EEPROM Timers
09 940C
940C
0A 0009
PROGRAM
Flash0009
ROM ALU

PC: 3
0
9
1
5
2
A
7
4
8
B
6 Data
13bit

16bit
CPU Bus
Instruction dec.
Program
Bus

Interrupt Other
OSC Ports
Unit Peripherals

I/O
PINS

10
Reading
• The AVR Microcontroller and Embedded Systems: Using
Assembly and C by Mazidi et al., Prentice Hall

– Chapter-2: Complete

11
THANK YOU

You might also like