Embedded Systems 419
blocks. ATmega8 offers 8K bytes of program memory in the form of Flash, arranged as 4K×16-bit as all
instructions of ATmega8 are 16-bit or 32-bit wide.
For the purpose of maintaining the security of program memory, the 8K Flash is divided in two parts,
as shown in Figure 14.5. The lower part (with higher addresses) is designated as boot ash-section and
the upper part (with lower addresses) is reserved for application ash-section. The boundary between
boot-section and application-section is software programmable.
The total area of SRAM in ATmega8 is 1K bytes plus the area of general purpose registers and I/O
registers, which makes a total of 1,120 bytes, as shown in Figure 14.6. The lowest 32 address locations
within these 1,120 bytes of SRAM are reserved for 32 general purpose 8-bit registers, including three
index registers, namely X, Y and Z. We have already indicated about the register-to-register architecture,
Figure 14.5 Program memory (Flash) of ATmega8
adopted by ATmega8, allowing any of these registers to also serve the purpose of accumulator regarding
result storage.
Next 64 addresses within SRAM (refer Figure 14.6 ) are designated as I/O registers. Note that these
I/O registers have two types of addresses. One is the absolute address, as indicated in Figure 14.6
(0020H to 005FH). Their alternate addresses are from 00H to 3FH and any one of these I/O registers
may be referred through either of these two addresses. In ATmega8, each of these 8-bit I/O registers has
its own special function. For example, one of the I/O register is designated as SREG to accommodate
several ag-bits re ecting the results of some arithmetic operation. Similarly, there are I/O registers for
proper functioning of ADC, WDT, Timers and so on. The third zone of SRAM, located at the highest
address, offers 1024 bytes of scratch-pad area. These 8-bit locations may be utilized for any general
purpose data storage.
The area of EEPROM within ATmega8 is 512 bytes or 1/2 K. The reader may ask a question here
about the purpose of providing on-chip EEPROM in ATmega8. As a matter of fact, in general, some
program memory (FLASH in this case) and data memory (SRAM in this case) are generally offered by
any microcontroller for permanent and temporary data storage. Then, what is the purpose of providing
an additional storage area? To answer this question, it may be pointed out that EEPROM is the best
place to store those user-de ned data, which are permanent or semi-permanent in nature. For example,
if any system, designed around ATmega8, is to store a password of the user, it cannot be stored within
SRAM as it would not be available after switching off the system. On the other hand, FLASH is meant
for storing the program. Moreover FLASH does not permit byte-wise erasing facility, which is a must to
store the semi-permanent type of information, like a user-password. As byte-wise erasing and run-time
writing is allowed in case of EEPROM, it is an ideal choice for such type of information storage in a
exible system.
M14_GHOS1557_01_SE_C14.indd 419M14_GHOS1557_01_SE_C14.indd 419 4/29/11 5:28 PM4/29/11 5:28 PM