SlideShare ist ein Scribd-Unternehmen logo
1 von 143
Downloaden Sie, um offline zu lesen
Embedded System PART 1
ENG.KEROLES SHENOUDA
1
Index
 Introduction to COMPUTER SYSTEM
 Memory
 I/O Unit
 Microprocessor
 The internal structure of a microprocessor.
 Central Processing Unit (CPU)
 Arithmetic and logic unit (ALU)
 Control unit
 CPU Interactions
 Clocks
 Cache Memory (L1 and L2) Cache
2
Index 3
 Special Purpose Registers
 PC Program Counter Register
 Instruction Register IR
 Instruction Decoder ID
 STACK Pointer SP Register
 STACK Pointer SP Register
 Status Register (SREG)
 Status Register (SREG)
 Index Register (X,Y)
 Accumulator Registers (A,B)
 General purpose Registers (R1,R2,R3,….)
Index 4
 Microcontroller
 Microcontroller Vs Microprocessor Vs SOC
 von Neumann Architecture
 Harvard Architecture
 pipeline
 CIS Vs RISC
 AVR different groups
Index 5
 GPIO/DIO/IO Module
 Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
 DIO_LAB1
 DIO_LAB2
 DIO_Project1:
LED Matrix 8*8
 quiz1: 7- segment “assembly Code”
 DIO_LAB3:Two- digital Display Module
DIO_Project2
Seven Segment Digital Clock
 References
Introduction to COMPUTER SYSTEM
A computer is a programmable machine that receives input, stores and manipulates
data//information, and provides output in a useful format.
6
BLOCK DIAGRAM OF A BASIC COMPUTER
SYSTEM
ROM RAM I/O
interface
I/O
devicesCPU
7
Basic computer system consist of a Central processing unit (CPU),
memory (RAM and ROM), input/output (I/O) unit.
Block diagram of a basic computer system
Address bus
Data bus Control
bus
Basic component of microcomputer
1. CPU - Central Processing Unit
 the portion of a computer system that carries out the instructions of a computer
program
 the primary element carrying out the computer's functions. It is the unit that reads
and executes program instructions.
 The data in the instruction tells the processor what to do.
8
Pentium D dual core processors
 physical devices used to store data or programs (sequences of
instructions) on a temporary or permanent basis for use in an electronic
digital computer.
 Computer main memory comes in two principal varieties: random-access
memory (RAM) and read-only memory (ROM).
 RAM can be read and written to anytime the CPU commands it, but
ROM is pre-loaded with data and software that never changes, so the
CPU can only read from it.
 ROM is typically used to store the computer's initial start-up instructions.
 In general, the contents of RAM are erased when the power to the
computer is turned off, but ROM retains its data indefinitely.
 In a PC, the ROM contains a specialized program called the BIOS that
orchestrates loading the computer's operating system from the hard disk
drive into RAM whenever the computer is turned on or reset.
9
Memory
Input/output (I/O), refers to the communication between an information
processing system (such as a computer), and the outside world possibly a
human, or another information processing system.
 Inputs are the signals or data received by the system, and outputs are
the signals or data sent from it
 Devices that provide input or output to the computer are called
peripherals
 On a typical personal computer, peripherals include input devices like
the keyboard and mouse, and output devices such as the display and
printer. Hard disk drives, floppy disk drives and optical disc drives serve
as both input and output devices. Computer networking is another form
of I/O.
10
I/O Unit
Microcontroller vs Microprocessor 11
A Microcontroller is basically a computer on a chip. It differs form normal desktop or laptop
computers in that a microcontroller is an application specific computer that usually runs
a single program performing dedicated task(s) while the the later two are general purpose
computers that can run numerous programs depending on a users needs. A microcontroller
contains on chip CPU, input/output interface, memory, clock, timer, and an assortment of of
other peripherals.
A Microprocessor on the other hand is just a CPU one
has to add externally memory, clock, input/output
interfaces, timer and all other needed peripheral. This is
the reason a microprocessor has so many pins.
Microprocessor
 There are five important components in a microprocessor. They are Arithmetic and
Logic Unit (ALU), Control Unit, Registers, Instruction Decoder and Data Bus but the
first three are considered significant components. The block diagram of a
microprocessor with these basic components is shown below.
12
Microprocessor
 The internal structure
of a microprocessor.
13
Central Processing Unit (CPU)
Arithmetic / Logic Unit
Registers
Control Unit
Small, fast
storage areas for
instructions and
data
Performs calculations
and decisions
Coordinates
processing steps
14
7-
15The Little Man Computer
The Processor
 The processor is the "brain" of the computer system.
 Main processor is called the Central Processing Unit (CPU).
 A particular computer will have a particular type of processor, such as a Pentium
or a SPARC chip.
 Co-processors assist the CPU with some of the processing functions. Examples:
 Math co-processors handle heavy duty math processing
 Graphics coprocessors speed up the display of graphics onto the monitor
16
Internal structure and basic operation of
microprocessor
ALU Register
Section
Control and timing
section
Address bus
Data bus
Control bus
17
Block diagram of a microprocessor
Arithmetic and logic unit (ALU)
 The component that performs the arithmetic and logical operations
 the most important components in a microprocessor, and is typically the
part of the processor that is designed first.
 able to perform the basic logical operations (AND, OR), including the
addition operation.
 The inclusion of inverters on the inputs enables the same ALU hardware
to perform the subtraction operation (adding an inverted operand),
and the operations NAND and NOR.
18
Internal structure of ALU
2 bits of ALU 4 bits of ALU
19
Control unit
 The circuitry that controls the flow of information through the
processor, and coordinates the activities of the other units within it.
 In a way, it is the "brain within the brain", as it controls what happens
inside the processor, which in turn controls the rest of the PC.
 On a regular processor, the control unit performs the tasks of
fetching, decoding, managing execution and then storing results.
20
Internal structure of control unit
21
Memory
Computer Memory - millions/billions of on/off charges
Divided into:
 Bits 0 or 1
 Bytes Groups of 8 bits A byte is the smallest unit of
storage. (Can hold one text character)
 WordsGroups of bits/bytes (8, 16, 32, 64-bits)
22
Memory
Storage is usually too large to be expressed in bytes or
words. Instead we use:
 Kilobyte (KB) = 1024 bytes(210 bytes)
 Megabyte (MB) = 1024 x 1024 bytes or one
million bytes (220 bytes)
 Gigabyte (GB) = 1024 x 1024 x 1024 bytes or
one trillion bytes (230 bytes)
 Terabyte (TB) = 1024 x 1024 x 1024 x 1024 bytes
one quadrillion bytes (240 bytes)
23
Main Memory
 Each computer has a specific word size
 Word sizes vary from computer to computer.
 Word size is an even multiple of a bytes.
 Each word within memory can hold either
 data or
 program instructions
24
Main Memory
5248
5249
5250
5251
5252
5253
5254
5255
5256
A word is stored in
consecutive
memory bytes.
10011010
Each memory cell stores a
set number of bits (some
computers use 8 bits/one
byte, others use words)
Each memory cell
has a numeric
address, which
uniquely identifies
its location
25
CPU and Memory
 CPU can interact with main memory in two ways:
 It can write a byte/word to a given memory location.
 The previous bits that were in that location are destroyed
 The new bits are saved for future use.
 It can read a byte/word from a given memory location.
 The CPU copies the bits stored at that location and stores them in a CPU
register
 The contents of the memory location are NOT changed.
26
Main Memory Characteristics
 Very closely connected to the CPU.
 Contents are quickly and easily changed.
 Holds the programs and data that the
processor is actively working with.
 Interacts with the processor millions of times
per second.
 Nothing permanent is kept in main memory.
27
Secondary Storage Characteristics
 Connected to main memory through a bus and a
device controller.
 Contents are easily changed, but access is very
slow compared to main memory.
 Only occasionally interacts with CPU.
 Used for long-term storage of programs and data.
 Much larger than main memory (GBs vs. MBs).
28
Program Instructions
 Programs instructions are stored in secondary storage
(hard disks, CD-ROM, DVD).
 To process data, the CPU requires a working area
 Uses Main Memory
 Also called: RAM (random access memory),
primary storage, and internal memory.
 Before a program is run, instructions must first be copied
from the slow secondary storage into fast main memory
 Provides the CPU with fast access to instructions to
execute.
29
Instructions
 An instruction is a sequence of bits.
 A simple instruction format may consist of an
operation code (op code) and an address or
operands.
Op Code Operands / Address
 Instructions tell the computer’s CPU what to do.
30
Instructions
 The operation code specifies the operation the
computer is to carry out (add, compare, etc)
 The operand/address area can store an operand or an
address
 An operand is a specific value or a register number
 An address allows the instruction to refer to a
location in main memory
 The CPU runs each instruction in the program,
starting with instruction 0, using the fetch-decode-
execute cycle.
31
Fetch-Decode-Execute Cycle
 During the fetch part, the CPU fetches the next
instruction from the address contained in the
Program Counter and places the instruction in
the Instruction Register.
 When a program starts, the program counter contains 0,
so the instruction at address 0 is fetched.
 As soon as an instruction is fetched, the CPU
adds 1 word to the contents of the Program
Counter, so that it will contain the address of the
next sequential instruction.
32
Fetch-Decode-Execute Diagram
Program Counter (PC)
3023
Instruction Register
General Purpose Registers
Fetch
Get instruction and
increment PC
CPU
…
3020
3021
3022
3023
3024
3025
3026
3027
3028
…
Main Memory
add r3, r1, r2
33
45
add r3, r1, r2
r1
r2
r378
3024
Execute
In this case add r1 and
r2 and put result in r3.
Decode
Determine what the
instruction is (add)
Then begin again by Fetching the instruction in 3024….
33
Clocks
 Computer systems have an internal clock, which is used to synchronize
their activities.
 Processors run at a particular clock speed.
 Clock speed is measured in Hertz
 One Hertz is one clock tick per second.
 MHz means mega Hertz
One MHz is one million clock ticks per second.
The clock speed determines how fast instructions can be run
34
Access to Instructions
The hard disk is too slow to provide instructions to the CPU.
So programs are first loaded into main memory, which is much faster.
The CPU can then access the instructions more quickly.
35
Cache Memory
 But as CPU speeds became faster, the main
memory couldn’t provide the CPU with the
instructions at a fast enough rate.
 So even faster memory ( cache memory) is
now placed between the CPU and main
memory to provide the instructions at an
quicker rate to the CPU.
36
Cache Memory
When an instruction or data is accessed from main memory, it is placed in
the cache. Second and subsequent use of the same instruction/data will
then be faster, since it is accessed directly from the cache.
37
Primary and Secondary
Cache Memory
 Most modern CPUs now have a cache
memory (L1), on the same silicon wafer as
the CPU, to provide the CPU with
instructions at the same clock speed as the
CPU.
 An additional off-the-chip secondary cache
(L2) may also interact with the CPU at a
slower speed.
38
L1 and L2 Cache Memory 39
User view of Computer Systems
Software that
controls the
hardware devices
Operating System –
- the user interface
Applications
e.g. Word, Netscape, etc
40
Register sets
 The register section/array consists completely of circuitry used to
temporarily store data or program codes until they are sent to the
ALU or to the control section or to memory.
 The number of registers are different for any particular CPU and the
more register a CPU have will result in easier programming tasks.
 Registers are normally measured by the number of bits they can hold,
for example, an "8-bit register" or a "32-bit register".
41
7-
42Registers
 Use of Registers
 Scratchpad for currently executing program
 Holds data needed quickly or frequently
 Stores information about status of CPU and currently executing program
 Address of next program instruction
 Signals from external devices
 General Purpose Registers
 User-visible registers
 Hold intermediate results or data values, e.g., loop counters
 Equivalent to LMC’s calculator
 Typically several dozen in current CPUs
43
PC Program Counter Register 44
Instruction Register IR 45
Instruction Decoder ID 46
STACK Pointer SP Register 47
STACK Pointer SP Register 48
Status Register (SREG) 49
Status Register (SREG) 50
51
ATMega32 Programmer Model: Registers (SR)
CPU
PC
ALU
registers
R1
R0
R15
R2 …
R16
R17
…
R30
R31
Instruction Register
Instruction decoder
SREG: I T H S V N CZ
$0000
$0001
$0020
General
purpose
RAM
(SRAM)
$001F
$005F
TWBR
TWSR
SPH
SREG
...
General
Purpose
Registers
Standard IO
Registers
$00
$01
$3E
$3F
$0060
......
Data Address
Space
IO Address
...
$FFFF
SREG:
Carry
Zero
Negative
oVerflow
Sign
N+VHalf carry
Temporary
Interrupt
H S V N CZTI
52
ATMega32 Programmer Model: Registers (SR)
CPU
PC
ALU
registers
R1
R0
R15
R2 …
R16
R17
…
R30
R31
Instruction Register
Instruction decoder
SREG: I T H S V N CZ
$0000
$0001
$0020
General
purpose
RAM
(SRAM)
$001F
$005F
TWBR
TWSR
SPH
SREG
...
General
Purpose
Registers
Standard IO
Registers
$00
$01
$3E
$3F
$0060
......
Data Address
Space
IO Address
...
$FFFF
SREG:
Carry
Zero
Negative
oVerflow
Sign
N+VHalf carry
Temporary
Interrupt
H S V N CZTI
Example: Show the status of the C, H, and Z flags after the addition of 0x38
and 0x2F in the following instructions:
LDI R16, 0x38 ;R16 = 0x38
LDI R17, 0x2F ;R17 = 0x2F
ADD R16, R17 ;add R17 to R16
Solution: 1
$38 0011 1000
+ $2F 0010 1111
$67 0110 0111 R16 = 0x67
C = 0 because there is no carry beyond the D7 bit.
H = 1 because there is a carry from the D3 to the D4 bit.
Z = 0 because the R16 (the result) has a value other than 0 after the addition.
Example: Show the status of the C, H, and Z flags after the addition of
0x9C and 0x64 in the following instructions:
LDI R20, 0x9C
LDI R21, 0x64
ADD R20, R21 ;add R21 to R20
Solution: 1
$9C 1001 1100
+ $64 0110 0100
$100 1 0000 0000 R20 = 00
C = 1 because there is a carry beyond the D7 bit.
H = 1 because there is a carry from the D3 to the D4 bit.
Z = 1 because the R20 (the result) has a value 0 in it after the addition.
Example: Show the status of the C, H, and Z flags after the subtraction of
0x23 from 0xA5 in the following instructions:
LDI R20, 0xA5
LDI R21, 0x23
SUB R20, R21 ;subtract R21 from R20
Solution:
$A5 1010 0101
- $23 0010 0011
$82 1000 0010 R20 = $82
C = 0 because R21 is not bigger than R20 and there is no borrow from D8 bit.
Z = 0 because the R20 has a value other than 0 after the subtraction.
H = 0 because there is no borrow from D4 to D3.
Example: Show the status of the C, H, and Z flags after the subtraction of
0x73 from 0x52 in the following instructions:
LDI R20, 0x52
LDI R21, 0x73
SUB R20, R21 ;subtract R21 from R20
Solution:
$52 0101 0010
- $73 0111 0011
$DF 1101 1111 R20 = $DF
C = 1 because R21 is bigger than R20 and there is a borrow from D8 bit.
Z = 0 because the R20 has a value other than zero after the subtraction.
H = 1 because there is a borrow from D4 to D3.
Example: Show the status of the C, H, and Z flags after the subtraction of
0x9C from 0x9C in the following instructions:
LDI R20, 0x9C
LDI R21, 0x9C
SUB R20, R21 ;subtract R21 from R20
Solution:
$9C 1001 1100
- $9C 1001 1100
$00 0000 0000 R20 = $00
C = 0 because R21 is not bigger than R20 and there is no borrow from D8 bit.
Z = 1 because the R20 is zero after the subtraction.
H = 0 because there is no borrow from D4 to D3.
Index Register (X,Y) 53
Accumulator Registers (A,B) 54
General purpose Registers (R1,R2,R3,….)
 Most instructions have direct access to all registers ▫ LD, MUL
 Some only operate on R16-R31
 ▫ ANDI, CPI, SUBI, MULS
 A few operate only on R16:R23
 ▫ Special multiply operations
 Double word operations operate on register pairs (R24-31)
 Most single-byte register or register+immediate operations are single cycle
instructions
55
Instruction Set Architecture ISA 56
57
AVR Assembler Statement
• The Assembler works on source files containing instruction mnemonics, labels and directives.
The instruction mnemonics and the directives often take operands.
• Code lines should be limited to 120 characters.
• Every input line can be preceded by a label, which is an alphanumeric string terminated by a
colon. Labels are used as targets for jump and branch instructions and as variable names in
Program memory and RAM.
• An input line may take one of the five following forms:
<label> <opcode> <operand> <;comments>
<label> <opcode> <operands> <;comments>
<label> <directive> <operands> <;comments>
Comments
Empty line
test: rjmp test ; Infinite loop (Instruction)
main: ldi R16, 9 ; store value 9 into register R16
label: .EQU var1=100 ; Set var1 to 100 (Directive)
.EQU var2=200 ; Set var2 to 200
; Pure comment line
58
AVR Assembler Output FilesEDITOR
PROGRAM
ASSEMBLER
PROGRAM
DOWNLOAD TO
AVR ’s FLASH
DOWNLOAD TO
AVR’s EEPROM
myfile.asm
myfile.objmyfile.eep myfile.hex myfile.map myfile.lst
59
AVR Assembler: Example
; Start on the flash ram's address 0
.org 0
000000 e009 main: ldi R16, 9
000001 e016 ldi R17, 6
000002 0f10 add R17, R16
000003 ef2f ldi R18, 255
000004 bb27 out DDRB, R18
000005 bb18 out PORTB, R17
000006 cff9 rjmp main
LC
Machine
code
Assembly
code
Assembly complete, 0 errors, 0 warnings
Instruction Set Architecture ISA 60
Instruction Set Architecture ISA 61
Instruction Life Cycle 62
Microprocessor revision (fun way) 63
Microprocessor revision (fun way) 64
Microprocessor revision (fun way) 65
Microprocessor revision (fun way) 66
Microprocessor revision (fun way) 67
Microcontroller
 Microcontrollers are basically used in embedded systems. Computerized or digital
control of devices is made plausible with the development of microcontrollers. The
development process of microcontroller is similar to that of a microprocessor.
 Microcontrollers can be classified based on bus width, memory structure and
instruction set. Bus width indicates the size of the data bus. Microcontrollers can be
classified as 8 – bit, 16 – bit or 32 – bit based on the bus width. Higher bus widths
often result in better performance.
68
69
What is the difference between microprocessor, microcontroller and
microcomputer...?
70
MICROPROCESSOR MICROCONTROLLER
71
Microprocessor assimilates the
function of a central processing unit
(CPU) on to a single integrated circuit
(IC).
Microcontroller can be considered as
a small computer which has a
processor and some other
components in order to make it a
computer.
Microprocessors are mainly used in
designing general purpose systems
from small to large and complex
systems like super computers.
Microcontrollers are used in
automatically controlled devices.
MICROPROCESSOR MICROCONTROLLER
72
Microprocessors are basic
components of personal computers.
Microcontrollers are generally used in
embedded systems
Computational capacity of
microprocessor is very high. Hence
can perform complex tasks.
Less computational capacity when
compared to microprocessors. Usually
used for simpler tasks.
A microprocessor based system can
perform numerous tasks.
A microcontroller based system can
perform single or very few tasks.
MICROPROCESSOR MICROCONTROLLER
73
Microprocessors have integrated Math Coprocessor.
Complex mathematical calculations which involve
floating point can be performed with great ease.
Microcontrollers do not have math coprocessors. They
use software to perform floating point calculations
which slows down the device.
The main task of microprocessor is to perform the
instruction cycle repeatedly. This includes fetch,
decode and execute.
In addition to performing the tasks of fetch, decode
and execute, a microcontroller also controls its
environment based on the output of the instruction
cycle.
In order to build or design a system (computer), a
microprocessor has to be connected externally to
some other components like Memory (RAM and ROM)
and Input / Output ports.
The IC of a microcontroller has memory (both RAM
and ROM) integrated on it along with some other
components like I / O devices and timers.
MICROPROCESSOR MICROCONTROLLER
74
The overall cost of a system built
using a microprocessor is high. This is
because of the requirement of
external components.
Cost of a system built using a
microcontroller is less as all the
components are readily available.
Generally power consumption and
dissipation is high because of the
external devices. Hence it requires
external cooling system.
Power consumption is less.
The clock frequency is very high
usually in the order of Giga Hertz.
Clock frequency is less usually in the
order of Mega Hertz.
MICROPROCESSOR MICROCONTROLLER
75
Instruction throughput is given higher priority
than interrupt latency.
In contrast, microcontrollers are designed to
optimize interrupt latency.
Have few bit manipulation instructions Bit manipulation is powerful and widely used
feature in microcontrollers. They have
numerous bit manipulation instructions.
Generally microprocessors are not used in
real time systems as they are severely
dependent on several other components.
Microcontrollers are used to handle real time
tasks as they are single programmed, self
sufficient and task oriented devices.
Microcontroller Vs Microprocessor
 https://www.youtube.com/watch?v=bJY78VIaPCE
76
Embedded System Classifications
 There are two main families of embedded
system platforms:
 MICROCONTROLLER Family
 High Performance (System On Chip) SOC Platform Family
77
78
79
SOCs Examples 80
microcontrollers and
SoC(System on Chip).
 https://www.youtube.com/watch?v=yTKg8LZoIVE
81
Conclusion
 SOC is the full system, often the computer on a chip, or at least that is the goal.
They are very powerful compared to mere micro controllers. SOC may have large
amount of memory, peripheral interfaces, radio/wireless connection.May be
multicore.
Microcontrollers are processor chips with inbuilt peripheral components,
ADC,DAC and some memory. Designing a system is easier with these than with a
raw microprocessor.
Microprocessors are raw processors with minimal ALU+ registers without
any peripheral components. You need to connect other chips to make it useful.
82
Von Neumann Vs Harvard 83
Earlier microprocessors made use of Von Neumann
architecture where the data and instructions
(programs) are stored in the same memory. Even
though this architecture is simple, there are many draw
backs. One of the major drawbacks is that instruction and
data cannot be accessed at the same time as they share
a single data bus.
This often degrades the overall performance of the
device. Later, Harvard architecture is introduced which
makes use of separate program and data memories
with separate buses so that both data and
instructions can be accessed at the same time. Later
Modified Harvard Architecture is developed in which the
program memory is accessed as if it were data memory
von Neumann 84
• Same memory holds data, instructions.
• A single set of address/data buses
between CPU and memory
Harvard Architecture
 Separate memories for data and instructions.
 Two sets of address/data buses between CPU and memory
85
Harvard architecture
Address bus
Data bus
Control bus
Address bus
Data bus
Control bus
CPU Address bus
Data bus
Control bus
Data
Memory
Code
Memory
CPU
Code
Memory
Data
Memory
Von Neumann architecture
Von Neumann vs. Harvard architecture 86
pipeline 87
Computer Systems
Not All Processors Are Created Equal
Newer machines use specialized processor chips that
have been developed to speed up the processing of
data.
 CISC - Complex instruction set computer
 Large instruction set, many formats
 RISC - Reduced instruction set computer
 Small instruction set, single or small variations in
format
 MPP - Massive parallel processing
 Many CPUs working in parallel
88
CIS Vs RISC 89
CIS Vs RISC 90
At mega 32
Atmel family Flash size
40 pins (4 port * 8)
Vref>>>ADC
91
AVR different groups 92
 Classic AVR
e.g. AT90S2313, AT90S4433
 Mega
e.g. ATmega8, ATmega32, ATmega128
 Tiny
e.g. ATtiny13, ATtiny25
 Special Purpose AVR
e.g. AT90PWM216,AT90USB1287
93
ATmega128
ATtiny44
Atmel group
Flash =128K
Atmel
Flash =4K
AT90S4433
Atmel Classic
group
Flash =4KTiny
group
AVR part numbers
94
ATMega32 Programmer Model: Memory
1. 2KB SRAM
– For temporary data storage
– Memory is lost when power is shut
off (volatile)
– Fast read and write
2. 1KB EEPROM
– For persistent data storage
– Memory contents are retained when
power is off (non-volatile)
– Fast read; slow write
– Can write individual bytes
3. 32KB Flash Program Memory
– Used to store program code
– Memory contents retained when
power is off (non-volatile)
– Fast to read; slow to write
– Can only write entire “blocks” of
memory at a time
– organized in 16-bit words
(16KWords)
95
ATMega32 Programmer Model: Memory
Type Flash RAM EEPROM
F_END Size, kB RAMEND Size, kB E_END Size, kB
Atmega8 $0FFF 8 $045F 1 $1FF 0.5
Atmega32 $3FFF 32 $085F 2 $3FF 1
Atmega64 $7FFF 64 $10FF 4 $7FF 2
Atmega128 $FFFF 128 $10FF 4 $FFF 4
• AVR microcontrollers are Harvard architecture.
This means, that in this architecture are
separate memory types (program memory and
data memory) connected with distinct buses.
Such memory architecture allows processor to
access program memory and data memory at
the same time. This increases performance of
MCU comparing to CISC architecture, where
CPU uses same bus for accessing program
memory and data memory.
• Each memory type has its own address space:
96ATMega32 Programmer Model: Data
Memory
• GPRs (general purpose
registers),
• Special Function Registers
(SFRs), and
• Internal data SRAM.
The data memory is composed
of three parts:
97ATMega32 Programmer Model:I/O Registers
(SFRs)
• The I/O memory is dedicated to specific
functions such as status register, timers,
serial communication, I/O ports, ADC and
etc.
• Function of each I/O memory location is
fixed by the CPU designer at the time of
design. (because it is used for control of
the microcontroller and peripherals)
• AVR I/O memory is made of 8 bit
registers.
• All of the AVRs have at least 64 bytes of
I/O memory location. (This 64 bytes
section is called standard I/O memory)
• In other microcontrollers, the I/O registers
are called SFRs (Special Function
Registers)
NameAddress
I/O Mem.
$00 $20 TWBR
$01 $21 TWSR
$04 $24 ADCL
$05 $25 ADCH
$02 $22 TWAR
$03 $23 TWDR
$06 $26 ADCSRA
$07 $27 ADMUX
$08 $28 ACSR
$09 $29 UBRRL
$0A $2A UCSRB
$0B $2B UCSRA
$0C $2C UDR
$0D $2D SPCR
$0E $2E SPSR
$0F $2F
PIND$10 $30
DDRD$11 $31
PORTD$12 $32
PINC$13 $33
DDRC$14 $34
PORTC$15 $35
PINB$16 $36
DDRB$17 $37
PORTB$18 $38
PINA$19 $39
DDRA$1A $3A
PORTA$1B $3B
EECR$1C $3C
EEDR$1D $3D
EEARL$1E $3E
EEARH$1F $3F
SPDR
NameAddress
I/O Mem.
NameAddress
I/O Mem.
UBRRC
$20 $40
UBRRH
$21 $41 WDTCR
$22 $42 ASSR
$23 $43 OCR2
$24 $44 TCNT2
$25 $45 TCCR2
$26 $46 ICR1L
$27 $47 ICR1H
$28 $48 OCR1BL
$29 $49 OCR1BH
OCR1AH$2B $4B
SFIOR$30 $50
OCDR
$31 $51
OSCCAL
$32 $52
TCCR0$33 $53
MCUCSR$34 $54
MCUCR$35 $55
TWCR$36 $56
SPMCR$37 $57
TIFR$38 $58
TIMSK$39 $59
TCNT1L$2C $4C
TCNT1H$2D $4D
TCCR1B$2E $4E
TCCR1A$2F $4F
TCNT0
$3A $5A
GICR$3B $5B
OCR0$3C $5C
SPL$3D $5D
SPH$3E $5E
GIFR
OCR1AL$2A $4A SREG$3E $5E
GPIO/DIO/IO
FOR ATMEGA32
98
99
ATMega32 Pin out & Descriptions
These pins are used
to connect external
crystal or RC
oscillator
Provides supply
voltage to the chip.
It should be
connected to +5
Supply voltage for
ADC and portA.
Connect it to VCC
Clears all the
registers and
restart the
execution of
program
Reference voltage
for ADC
Port APort B
Port D
Port C
100
ATMega32 Pin out & Descriptions
Mega32/Mega16
(XCK/T0) PB0
(T1) PB1
(INT2/AIN0) PB2
(OC0/AIN1) PB3
(SS) PB4
(MOSI) PB5
(MISO) PB6
(SCK) PB7
RESET
VCC
XTAL2
GND
XTAL1
(RXD) PD0
(TXD) PD1
(INT0) PD2
(INT1) PD3
(OC1B) PD4
(OC1A) PD5
(ICP) PD6
PA0 (ADC0)
PA1 (ADC1)
PA2 (ADC2)
PA3 (ADC3)
PA4 (ADC4)
PA5 (ADC5)
PA6 (ADC6)
PA7 (ADC7)
AREF
AGND
PC7 (TOSC2)
AVCC
PC6 (TOSC1)
PC5 (TDI)
PC4 (TDO)
PC3 (TMS)
PC2 (TCK)
PC1 (SDA)
PC0 (SCL)
PD7 (OC2)
DDRA
PORTA
PINA
DDRB
PINB
PORTB
DDRC
PORTC
PINC
101
ATMega32 Pin out & Descriptions
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
102
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
103
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
104
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
105
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
106
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
107
Atmel-8155-8-bit-Microcontroller-AVR-
ATmega32A_Datasheet
108
HAND
WRITING
109
HAND
WRITING
111
ATMega32 Elementary I/O: LEDs
• LEDs must be connected the correct way round, the
diagram may be labeled a or + for anode and k
or - for cathode (yes, it really is k, not c, for
cathode!). The cathode is the short lead and there
may be a slight flat on the body of round LEDs. If
you can see inside the LED the cathode is the larger
electrode (but this is not an official identification
method).
• LEDs can be damaged by heat when soldering, but
the risk is small unless you are very slow. No special
precautions are needed for soldering most LEDs.
• LEDs are available in red, orange, amber, yellow,
green, blue and white. Blue and white LEDs are
much more expensive than the other colors. The
color of an LED is determined by the semiconductor
material, not by the coloring of the 'package' (the
plastic body).
An LED is a semiconductor device that converts electrical energy directly into a
discrete color of light
112
ATMega32 Elementary I/O: LEDs
• Never connect an LED directly to a battery or power supply! It will be destroyed
almost instantly because too much current will pass through and burn it out.
• LEDs must have a resistor in series to limit the current to a safe value, for quick
testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V
or less.
• The resistor value, R is given by:
• Estimate 1.5 - 2 V voltage drop (VL)
• Typically draws 10-20 mA (I)
Unless you know
what are you doing!
113ATMega32 Elementary I/O: LEDs
+5V
R
output pin
1
+3.2V
No current
Current
light
Estimate R =
voltage
current
=
5 – 1.8 – 0.4
13 x 10 -3 = 215 Ω ~ 220 Ω
easier to get
LED
no light
+5V
+5V
R
output pin
0
LED
+0.4V
Turning on an LED
Setting the pin to high will not
turn ON the LED
Setting the pin to low will turn
ON the LED
DIO_LAB1 114
Write A embedded C
Code
To toggle 3 Led on
sequential way
Then start a tick(pulse) by
Buzzer then
Rerun again
Port D pin 5,6,7 as output (LED)
Port D pin 4 (Buzzer)
step1
step2
step3
step4avr/io.h and util/delay.h
DIO_LAB1 Solution: Create ATMEGA32_registers.h to
be independent on avr/io.h 115
DIO_LAB1 Solution:
write the Code 116
DIO_LAB1 Solution:
write the Code 117
It will be helpful if you learned to Create
the ATMEGA32_Registers.h for All
Atmega32 Registers
118
DIO_Project1:
LED Matrix 8*8
119
DIO_Project1
Seven Segment Digital Clock
 Write a program for a 2-D Led array
(1*2 LCD) using all GPIO pins in
Atmeg32, that acts like a real screen.
The Screen is divided into two (8*8)
frames (characters), and write a two
functions that takes a character and
print it for each frame. And simulate
the project using proteus. the following
figure shows one frame
120
DIO_Project1
Seven Segment Digital Clock
 Say if we want to turn on LED D10 in
the matrix, we need to power the
PIN14 of module and ground the
PIN3 on module. With this the D10 will
turn ON. This is shown in the figure
below. This should be first check for
MATRIX to know everything in order.
121
DIO_Project1
Seven Segment Digital Clock
 Say if we want to turn on D1, we
need to power PIN9 of matrix and
ground the PIN13. With that LED D1
will glow. The current direction for this
case is shown in below figure.
122
DIO_Project1
Seven Segment Digital Clock
 Now for the tricky part, consider we
want to turn on both D1 and D10 at a
time. So we power both PIN9, PIN14
and ground both PIN13, PIN3. With
that we will have D2 and D9 ON
along with D1 and D10. It’s because
they share common terminals. So if we
want to turn LEDs along the diagonal,
we will be forced to turn ON all the
LEDs along the way. This is shown in
below figure.
123
DIO_Project1
Seven Segment Digital Clock
 So to eliminate this problem we will turn only one led on at a
time. Say at t=0m SEC, LED D1 is tuned ON. At t = 1m SEC, LED
D1 is tuned OFF and LED D2 is turned ON. Again at t=2 m SEC,
LED D2 is turned OFF and LED D1 is turned ON. This goes on.
 Now the trick is, the human eye cannot capture a frequency
more than 30 HZ. That is if a LED goes ON and OFF
continuously at a rate of 30HZ or more. The eye sees the LED
as continuously ON. However this is not the case. The LED will
be constantly turning ON and OFF. This technique is called
multiplexing.

 By using multiplexing, we will turn only one row at a time, and
there will be cycling around the 8 rows continuously. This
visualized as a completely turned ON matrix for a naked eye.
124
Multiplexing
With very speed
To render
Each row
125
Led 2 1 0
write embedded C program
“up/down binary Counter”
By three leds and two push button
0
1
7
……
sw0sw1
DIO_Quiz1
126
I/O: 7-Segment Display
 There are applications where you need to display a decimal
digit using a seven segment LED display.
 The display could represent e.g. the number of times a
switch was pressed.
 Digits 0-9 and hex A-F can be displayed by giving the
proper 7-segment codes
q g f e d c b a q g f e d c b a
0 0 1 1 1 1 1 1 8 1 1 1 1 1 1 1
1 0 0 0 0 1 1 0 9 1 1 0 0 1 1 1
2 1 0 1 1 0 1 1 A 1 1 1 0 1 1 1
3 1 0 0 1 1 1 1 b 0 0 1 1 1 1 1
4 1 1 0 0 1 1 0 C 0 1 1 1 0 0 1
5 1 1 0 1 1 0 1 d 1 0 1 1 1 1 0
6 1 1 1 1 1 0 1 E 1 1 1 1 0 0 1
7 0 0 0 0 1 1 1 F 1 1 1 0 0 0 1
127
I/O: 7-Segment Display
 Common-anode :
 requires VCC
 LED ON when Output is LOW.
 Common-cathode :
 NO VCC ,
 LED ON when Output is HIGH.
 TTL and CMOS devices are
normally not used to drive the
common-cathode display directly
because of current (mA)
requirement. A buffer circuit is
used between the decoder chips
and common-cathode display
128I/O: 7-Segment Display
129
I/O: 7-Segment Display
A 7-Segment LED could be attached as shown:
130I/O: 7-Segment Display
Or:
131DIO_Lab2 :
A 7-segment is connected to PORTA.
Write an assembly/embedded C Code
to Display 1 on the 7-segment.
ATmega32
8
PORTC
0
1
2
3
5
6
4
132DIO_Lab2 Solution: assembly
A 7-segment is connected to PORTA. Display 1 on the
7-segment.
ATmega32
8
PORTC
0
1
2
3
5
6
4
1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 0
DDRC
:
PORTC:
;
; DIO_lab2.asm
;
; Author : kkhalil
;
; Replace with your application code
LDI R20,0x06 ;R20 = 00000110 (binary)
OUT PORTC,R20 ;PORTC = R20
LDI R20,0xFF ;R20 = 11111111 (binary)
OUT DDRC,R20 ;DDRC = R20 ;Delay 1
;cycle latency
L1: RJMP L1
133
DIO_Lab3 :
Two- digital
Display Module
7 Segment Display
 DATA LINES:
- 7SEG_APORTC .4
- 7SEG_BPORTC .5
- 7SEG_CPORTC .6
- 7SEG_DPORTC .7
 DECIMAL POINT:
- 7SEG_DPPORTB .0
 ENABLE LINES
- 7SEG_EN1PORTC .2
- 7SEG_EN2PORTC .3
The trick is, the human eye cannot capture a frequency
more than 30 HZ. That is if a LED goes ON and OFF
continuously at a rate of 30HZ or more. The eye sees the
LED as continuously ON. However this is not the case.
The LED will be constantly turning ON and OFF. This
technique is called multiplexing.
DIO_Lab3 :Two- digital Display Module
 Write an embedded C Code to “up Counter” from 0 to 99.
134
DIO_Lab3 :Two- digital Display Module
 Write an embedded C Code to “up Counter” from 0 to 99.
135
DIO_Lab3 :Two- digital Display Module
 Write an embedded C Code to “up Counter” from 0 to 99.
136
DIO_Lab3 Solution:
 Write an embedded C Code to
“up Counter” from 0 to 99.
137
DIO_Project2:
Seven Segment Digital Clock
138
DIO_Project2
Seven Segment Digital Clock
 Our digital clock operates as follows. When the circuit is powered up the clock
starts at "00:00:00" for "HH:MM:SS". There are two push-button switches used to
set the time. Switch SW1 is for setting the minutes, when this button is pressed the
minutes in increase until it reaches 59 then reset and start counting from 0.
Switch SW2 is for setting the hours.
 All seven segment displays are driven by the same port (PortB). The microcontroller
through controls from PortC indicate which seven segment display each digit is
displayed on. Note that these Seven Segment Displays are common
cathode display.
139
DIO_Project2
Seven Segment
Digital Clock
140
DIO_Project2
Seven Segment Digital Clock
141
References
 https://docs.google.com/viewer?a=v&pid=sites&srcid=ZmtlLnV0bS5teXxyaWR6d
WFuLXMtd2Vic2l0ZXxneDo2ODU0NzlkM2JkOTg4MjRk
 http://www.avrprojects.net/index.php/avr-projects/sensors/38-humidity-and-
temperature-sensor-dht11?showall=&start=1
 http://www.cse.wustl.edu/~lu/cse467s/slides/dsp.pdf
 http://www.avr-tutorials.com/
 Microprocessor: ATmega32 (SEE3223-10)
http://ridzuan.fke.utm.my/microprocessor-atmega32-see3223-10
 http://circuitdigest.com/article/what-is-the-difference-between-microprocessor-
and-microcontroller
142
143

Weitere ähnliche Inhalte

Was ist angesagt?

What is AUTOSAR MCAL? Learn about the software module architecture and device...
What is AUTOSAR MCAL? Learn about the software module architecture and device...What is AUTOSAR MCAL? Learn about the software module architecture and device...
What is AUTOSAR MCAL? Learn about the software module architecture and device...Embitel Technologies (I) PVT LTD
 
Automotive embedded systems part3 v1
Automotive embedded systems part3 v1Automotive embedded systems part3 v1
Automotive embedded systems part3 v1Keroles karam khalil
 
Autosar fundamental
Autosar fundamentalAutosar fundamental
Autosar fundamentalOmkar Rane
 
AUTOSAR 403 CAN Stack
AUTOSAR 403 CAN StackAUTOSAR 403 CAN Stack
AUTOSAR 403 CAN StackRania Nabil
 
Automotive embedded systems part7 v1
Automotive embedded systems part7 v1Automotive embedded systems part7 v1
Automotive embedded systems part7 v1Keroles karam khalil
 
Automotive embedded systems part1 v1
Automotive embedded systems part1 v1Automotive embedded systems part1 v1
Automotive embedded systems part1 v1Keroles karam khalil
 
Autosar software component
Autosar software componentAutosar software component
Autosar software componentFarzad Sadeghi
 

Was ist angesagt? (20)

Automative basics v3
Automative basics v3Automative basics v3
Automative basics v3
 
Embedded C - Day 2
Embedded C - Day 2Embedded C - Day 2
Embedded C - Day 2
 
C programming session8
C programming  session8C programming  session8
C programming session8
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Misra c rules
Misra c rulesMisra c rules
Misra c rules
 
What is AUTOSAR MCAL? Learn about the software module architecture and device...
What is AUTOSAR MCAL? Learn about the software module architecture and device...What is AUTOSAR MCAL? Learn about the software module architecture and device...
What is AUTOSAR MCAL? Learn about the software module architecture and device...
 
C programming first_session
C programming first_sessionC programming first_session
C programming first_session
 
Automotive embedded systems part3 v1
Automotive embedded systems part3 v1Automotive embedded systems part3 v1
Automotive embedded systems part3 v1
 
Autosar fundamental
Autosar fundamentalAutosar fundamental
Autosar fundamental
 
Misra c
Misra cMisra c
Misra c
 
AUTOSAR 403 CAN Stack
AUTOSAR 403 CAN StackAUTOSAR 403 CAN Stack
AUTOSAR 403 CAN Stack
 
Automotive embedded systems part7 v1
Automotive embedded systems part7 v1Automotive embedded systems part7 v1
Automotive embedded systems part7 v1
 
Linux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platformLinux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platform
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
Automotive embedded systems part1 v1
Automotive embedded systems part1 v1Automotive embedded systems part1 v1
Automotive embedded systems part1 v1
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
Embedded C - Lecture 4
Embedded C - Lecture 4Embedded C - Lecture 4
Embedded C - Lecture 4
 
C programming session7
C programming  session7C programming  session7
C programming session7
 
Advanced C - Part 1
Advanced C - Part 1 Advanced C - Part 1
Advanced C - Part 1
 
Autosar software component
Autosar software componentAutosar software component
Autosar software component
 

Andere mochten auch (20)

C programming session7
C programming  session7C programming  session7
C programming session7
 
C programming part2
C programming part2C programming part2
C programming part2
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
C programming session3
C programming  session3C programming  session3
C programming session3
 
Microcontroller part 2
Microcontroller part 2Microcontroller part 2
Microcontroller part 2
 
K vector embedded_linux_workshop
K vector embedded_linux_workshopK vector embedded_linux_workshop
K vector embedded_linux_workshop
 
C programming first_session
C programming first_sessionC programming first_session
C programming first_session
 
Microcontroller part 3
Microcontroller part 3Microcontroller part 3
Microcontroller part 3
 
C programming session8
C programming  session8C programming  session8
C programming session8
 
C programming part4
C programming part4C programming part4
C programming part4
 
Microcontroller part 5
Microcontroller part 5Microcontroller part 5
Microcontroller part 5
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part4
C programming part4C programming part4
C programming part4
 
C programming session5
C programming  session5C programming  session5
C programming session5
 
Microcontroller part 7_v1
Microcontroller part 7_v1Microcontroller part 7_v1
Microcontroller part 7_v1
 
Microcontroller part 9_v1
Microcontroller part 9_v1Microcontroller part 9_v1
Microcontroller part 9_v1
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
Microcontroller part 2
Microcontroller part 2Microcontroller part 2
Microcontroller part 2
 
Microcontroller part 3
Microcontroller part 3Microcontroller part 3
Microcontroller part 3
 
Microcontroller part 6_v1
Microcontroller part 6_v1Microcontroller part 6_v1
Microcontroller part 6_v1
 

Ähnlich wie Microcontroller part 1

computer System UNit Every thing
computer System UNit Every thingcomputer System UNit Every thing
computer System UNit Every thingAbdul Rehman
 
computer devices and memory unit 2 notes.pdf
computer devices and memory unit 2 notes.pdfcomputer devices and memory unit 2 notes.pdf
computer devices and memory unit 2 notes.pdfshubhangisonawane6
 
Computer System.ppt
Computer System.pptComputer System.ppt
Computer System.pptjguuhxxxfp
 
Introduction to-microprocessor
Introduction to-microprocessorIntroduction to-microprocessor
Introduction to-microprocessorankitnav1
 
Introduction to-microprocessor
Introduction to-microprocessorIntroduction to-microprocessor
Introduction to-microprocessorankitnav1
 
The Basic Configuration of a Microcomputer
The Basic Configuration of a Microcomputer The Basic Configuration of a Microcomputer
The Basic Configuration of a Microcomputer Taminul Islam
 
Computer basics and i.o devices
Computer basics and i.o devicesComputer basics and i.o devices
Computer basics and i.o deviceskitturashmikittu
 
Computer-Processing-Devices.pdf
Computer-Processing-Devices.pdfComputer-Processing-Devices.pdf
Computer-Processing-Devices.pdfDKGAUTAMgautam
 
CPU (Central processing unit)
CPU (Central processing unit) CPU (Central processing unit)
CPU (Central processing unit) Razu Rahman
 
Components of-computer-2-1226486763942707-9
Components of-computer-2-1226486763942707-9Components of-computer-2-1226486763942707-9
Components of-computer-2-1226486763942707-9virendra kumar
 
Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11gajani121
 
08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)Akhila Dakshina
 
Ise iv-computer organization [10 cs46]-notes new
Ise iv-computer  organization [10 cs46]-notes newIse iv-computer  organization [10 cs46]-notes new
Ise iv-computer organization [10 cs46]-notes newdilshad begum
 

Ähnlich wie Microcontroller part 1 (20)

Cpu
CpuCpu
Cpu
 
computer System UNit Every thing
computer System UNit Every thingcomputer System UNit Every thing
computer System UNit Every thing
 
computer devices and memory unit 2 notes.pdf
computer devices and memory unit 2 notes.pdfcomputer devices and memory unit 2 notes.pdf
computer devices and memory unit 2 notes.pdf
 
Computer System.ppt
Computer System.pptComputer System.ppt
Computer System.ppt
 
Introduction to-microprocessor
Introduction to-microprocessorIntroduction to-microprocessor
Introduction to-microprocessor
 
Introduction to-microprocessor
Introduction to-microprocessorIntroduction to-microprocessor
Introduction to-microprocessor
 
Ppt Lesson 04
Ppt Lesson 04Ppt Lesson 04
Ppt Lesson 04
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
The Basic Configuration of a Microcomputer
The Basic Configuration of a Microcomputer The Basic Configuration of a Microcomputer
The Basic Configuration of a Microcomputer
 
Computer basics and i.o devices
Computer basics and i.o devicesComputer basics and i.o devices
Computer basics and i.o devices
 
Computer-Processing-Devices.pdf
Computer-Processing-Devices.pdfComputer-Processing-Devices.pdf
Computer-Processing-Devices.pdf
 
Components of a computer
Components of a computerComponents of a computer
Components of a computer
 
CPU (Central processing unit)
CPU (Central processing unit) CPU (Central processing unit)
CPU (Central processing unit)
 
Cpu ppt cse
Cpu ppt cseCpu ppt cse
Cpu ppt cse
 
Computer.pptx
Computer.pptxComputer.pptx
Computer.pptx
 
Components of-computer-2-1226486763942707-9
Components of-computer-2-1226486763942707-9Components of-computer-2-1226486763942707-9
Components of-computer-2-1226486763942707-9
 
Motorola 68hc11
Motorola 68hc11Motorola 68hc11
Motorola 68hc11
 
08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)
 
Ise iv-computer organization [10 cs46]-notes new
Ise iv-computer  organization [10 cs46]-notes newIse iv-computer  organization [10 cs46]-notes new
Ise iv-computer organization [10 cs46]-notes new
 
Microcontroller part 1
Microcontroller part 1Microcontroller part 1
Microcontroller part 1
 

Mehr von Keroles karam khalil (17)

C basics quiz part 1_solution
C basics quiz part 1_solutionC basics quiz part 1_solution
C basics quiz part 1_solution
 
Automotive embedded systems part6 v2
Automotive embedded systems part6 v2Automotive embedded systems part6 v2
Automotive embedded systems part6 v2
 
Automotive embedded systems part5 v2
Automotive embedded systems part5 v2Automotive embedded systems part5 v2
Automotive embedded systems part5 v2
 
Automotive embedded systems part4 v1
Automotive embedded systems part4 v1Automotive embedded systems part4 v1
Automotive embedded systems part4 v1
 
Quiz 9
Quiz 9Quiz 9
Quiz 9
 
C programming session10
C programming  session10C programming  session10
C programming session10
 
C programming session9 -
C programming  session9 -C programming  session9 -
C programming session9 -
 
Quiz 10
Quiz 10Quiz 10
Quiz 10
 
Homework 6
Homework 6Homework 6
Homework 6
 
Homework 5 solution
Homework 5 solutionHomework 5 solution
Homework 5 solution
 
Notes part7
Notes part7Notes part7
Notes part7
 
Homework 5
Homework 5Homework 5
Homework 5
 
Notes part6
Notes part6Notes part6
Notes part6
 
Homework 4 solution
Homework 4 solutionHomework 4 solution
Homework 4 solution
 
Notes part5
Notes part5Notes part5
Notes part5
 
Homework 4
Homework 4Homework 4
Homework 4
 
Homework 3 solution
Homework 3 solutionHomework 3 solution
Homework 3 solution
 

Kürzlich hochgeladen

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Kürzlich hochgeladen (20)

★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Microcontroller part 1

  • 1. Embedded System PART 1 ENG.KEROLES SHENOUDA 1
  • 2. Index  Introduction to COMPUTER SYSTEM  Memory  I/O Unit  Microprocessor  The internal structure of a microprocessor.  Central Processing Unit (CPU)  Arithmetic and logic unit (ALU)  Control unit  CPU Interactions  Clocks  Cache Memory (L1 and L2) Cache 2
  • 3. Index 3  Special Purpose Registers  PC Program Counter Register  Instruction Register IR  Instruction Decoder ID  STACK Pointer SP Register  STACK Pointer SP Register  Status Register (SREG)  Status Register (SREG)  Index Register (X,Y)  Accumulator Registers (A,B)  General purpose Registers (R1,R2,R3,….)
  • 4. Index 4  Microcontroller  Microcontroller Vs Microprocessor Vs SOC  von Neumann Architecture  Harvard Architecture  pipeline  CIS Vs RISC  AVR different groups
  • 5. Index 5  GPIO/DIO/IO Module  Atmel-8155-8-bit-Microcontroller-AVR- ATmega32A_Datasheet  DIO_LAB1  DIO_LAB2  DIO_Project1: LED Matrix 8*8  quiz1: 7- segment “assembly Code”  DIO_LAB3:Two- digital Display Module DIO_Project2 Seven Segment Digital Clock  References
  • 6. Introduction to COMPUTER SYSTEM A computer is a programmable machine that receives input, stores and manipulates data//information, and provides output in a useful format. 6
  • 7. BLOCK DIAGRAM OF A BASIC COMPUTER SYSTEM ROM RAM I/O interface I/O devicesCPU 7 Basic computer system consist of a Central processing unit (CPU), memory (RAM and ROM), input/output (I/O) unit. Block diagram of a basic computer system Address bus Data bus Control bus
  • 8. Basic component of microcomputer 1. CPU - Central Processing Unit  the portion of a computer system that carries out the instructions of a computer program  the primary element carrying out the computer's functions. It is the unit that reads and executes program instructions.  The data in the instruction tells the processor what to do. 8 Pentium D dual core processors
  • 9.  physical devices used to store data or programs (sequences of instructions) on a temporary or permanent basis for use in an electronic digital computer.  Computer main memory comes in two principal varieties: random-access memory (RAM) and read-only memory (ROM).  RAM can be read and written to anytime the CPU commands it, but ROM is pre-loaded with data and software that never changes, so the CPU can only read from it.  ROM is typically used to store the computer's initial start-up instructions.  In general, the contents of RAM are erased when the power to the computer is turned off, but ROM retains its data indefinitely.  In a PC, the ROM contains a specialized program called the BIOS that orchestrates loading the computer's operating system from the hard disk drive into RAM whenever the computer is turned on or reset. 9 Memory
  • 10. Input/output (I/O), refers to the communication between an information processing system (such as a computer), and the outside world possibly a human, or another information processing system.  Inputs are the signals or data received by the system, and outputs are the signals or data sent from it  Devices that provide input or output to the computer are called peripherals  On a typical personal computer, peripherals include input devices like the keyboard and mouse, and output devices such as the display and printer. Hard disk drives, floppy disk drives and optical disc drives serve as both input and output devices. Computer networking is another form of I/O. 10 I/O Unit
  • 11. Microcontroller vs Microprocessor 11 A Microcontroller is basically a computer on a chip. It differs form normal desktop or laptop computers in that a microcontroller is an application specific computer that usually runs a single program performing dedicated task(s) while the the later two are general purpose computers that can run numerous programs depending on a users needs. A microcontroller contains on chip CPU, input/output interface, memory, clock, timer, and an assortment of of other peripherals. A Microprocessor on the other hand is just a CPU one has to add externally memory, clock, input/output interfaces, timer and all other needed peripheral. This is the reason a microprocessor has so many pins.
  • 12. Microprocessor  There are five important components in a microprocessor. They are Arithmetic and Logic Unit (ALU), Control Unit, Registers, Instruction Decoder and Data Bus but the first three are considered significant components. The block diagram of a microprocessor with these basic components is shown below. 12
  • 13. Microprocessor  The internal structure of a microprocessor. 13
  • 14. Central Processing Unit (CPU) Arithmetic / Logic Unit Registers Control Unit Small, fast storage areas for instructions and data Performs calculations and decisions Coordinates processing steps 14
  • 16. The Processor  The processor is the "brain" of the computer system.  Main processor is called the Central Processing Unit (CPU).  A particular computer will have a particular type of processor, such as a Pentium or a SPARC chip.  Co-processors assist the CPU with some of the processing functions. Examples:  Math co-processors handle heavy duty math processing  Graphics coprocessors speed up the display of graphics onto the monitor 16
  • 17. Internal structure and basic operation of microprocessor ALU Register Section Control and timing section Address bus Data bus Control bus 17 Block diagram of a microprocessor
  • 18. Arithmetic and logic unit (ALU)  The component that performs the arithmetic and logical operations  the most important components in a microprocessor, and is typically the part of the processor that is designed first.  able to perform the basic logical operations (AND, OR), including the addition operation.  The inclusion of inverters on the inputs enables the same ALU hardware to perform the subtraction operation (adding an inverted operand), and the operations NAND and NOR. 18
  • 19. Internal structure of ALU 2 bits of ALU 4 bits of ALU 19
  • 20. Control unit  The circuitry that controls the flow of information through the processor, and coordinates the activities of the other units within it.  In a way, it is the "brain within the brain", as it controls what happens inside the processor, which in turn controls the rest of the PC.  On a regular processor, the control unit performs the tasks of fetching, decoding, managing execution and then storing results. 20
  • 21. Internal structure of control unit 21
  • 22. Memory Computer Memory - millions/billions of on/off charges Divided into:  Bits 0 or 1  Bytes Groups of 8 bits A byte is the smallest unit of storage. (Can hold one text character)  WordsGroups of bits/bytes (8, 16, 32, 64-bits) 22
  • 23. Memory Storage is usually too large to be expressed in bytes or words. Instead we use:  Kilobyte (KB) = 1024 bytes(210 bytes)  Megabyte (MB) = 1024 x 1024 bytes or one million bytes (220 bytes)  Gigabyte (GB) = 1024 x 1024 x 1024 bytes or one trillion bytes (230 bytes)  Terabyte (TB) = 1024 x 1024 x 1024 x 1024 bytes one quadrillion bytes (240 bytes) 23
  • 24. Main Memory  Each computer has a specific word size  Word sizes vary from computer to computer.  Word size is an even multiple of a bytes.  Each word within memory can hold either  data or  program instructions 24
  • 25. Main Memory 5248 5249 5250 5251 5252 5253 5254 5255 5256 A word is stored in consecutive memory bytes. 10011010 Each memory cell stores a set number of bits (some computers use 8 bits/one byte, others use words) Each memory cell has a numeric address, which uniquely identifies its location 25
  • 26. CPU and Memory  CPU can interact with main memory in two ways:  It can write a byte/word to a given memory location.  The previous bits that were in that location are destroyed  The new bits are saved for future use.  It can read a byte/word from a given memory location.  The CPU copies the bits stored at that location and stores them in a CPU register  The contents of the memory location are NOT changed. 26
  • 27. Main Memory Characteristics  Very closely connected to the CPU.  Contents are quickly and easily changed.  Holds the programs and data that the processor is actively working with.  Interacts with the processor millions of times per second.  Nothing permanent is kept in main memory. 27
  • 28. Secondary Storage Characteristics  Connected to main memory through a bus and a device controller.  Contents are easily changed, but access is very slow compared to main memory.  Only occasionally interacts with CPU.  Used for long-term storage of programs and data.  Much larger than main memory (GBs vs. MBs). 28
  • 29. Program Instructions  Programs instructions are stored in secondary storage (hard disks, CD-ROM, DVD).  To process data, the CPU requires a working area  Uses Main Memory  Also called: RAM (random access memory), primary storage, and internal memory.  Before a program is run, instructions must first be copied from the slow secondary storage into fast main memory  Provides the CPU with fast access to instructions to execute. 29
  • 30. Instructions  An instruction is a sequence of bits.  A simple instruction format may consist of an operation code (op code) and an address or operands. Op Code Operands / Address  Instructions tell the computer’s CPU what to do. 30
  • 31. Instructions  The operation code specifies the operation the computer is to carry out (add, compare, etc)  The operand/address area can store an operand or an address  An operand is a specific value or a register number  An address allows the instruction to refer to a location in main memory  The CPU runs each instruction in the program, starting with instruction 0, using the fetch-decode- execute cycle. 31
  • 32. Fetch-Decode-Execute Cycle  During the fetch part, the CPU fetches the next instruction from the address contained in the Program Counter and places the instruction in the Instruction Register.  When a program starts, the program counter contains 0, so the instruction at address 0 is fetched.  As soon as an instruction is fetched, the CPU adds 1 word to the contents of the Program Counter, so that it will contain the address of the next sequential instruction. 32
  • 33. Fetch-Decode-Execute Diagram Program Counter (PC) 3023 Instruction Register General Purpose Registers Fetch Get instruction and increment PC CPU … 3020 3021 3022 3023 3024 3025 3026 3027 3028 … Main Memory add r3, r1, r2 33 45 add r3, r1, r2 r1 r2 r378 3024 Execute In this case add r1 and r2 and put result in r3. Decode Determine what the instruction is (add) Then begin again by Fetching the instruction in 3024…. 33
  • 34. Clocks  Computer systems have an internal clock, which is used to synchronize their activities.  Processors run at a particular clock speed.  Clock speed is measured in Hertz  One Hertz is one clock tick per second.  MHz means mega Hertz One MHz is one million clock ticks per second. The clock speed determines how fast instructions can be run 34
  • 35. Access to Instructions The hard disk is too slow to provide instructions to the CPU. So programs are first loaded into main memory, which is much faster. The CPU can then access the instructions more quickly. 35
  • 36. Cache Memory  But as CPU speeds became faster, the main memory couldn’t provide the CPU with the instructions at a fast enough rate.  So even faster memory ( cache memory) is now placed between the CPU and main memory to provide the instructions at an quicker rate to the CPU. 36
  • 37. Cache Memory When an instruction or data is accessed from main memory, it is placed in the cache. Second and subsequent use of the same instruction/data will then be faster, since it is accessed directly from the cache. 37
  • 38. Primary and Secondary Cache Memory  Most modern CPUs now have a cache memory (L1), on the same silicon wafer as the CPU, to provide the CPU with instructions at the same clock speed as the CPU.  An additional off-the-chip secondary cache (L2) may also interact with the CPU at a slower speed. 38
  • 39. L1 and L2 Cache Memory 39
  • 40. User view of Computer Systems Software that controls the hardware devices Operating System – - the user interface Applications e.g. Word, Netscape, etc 40
  • 41. Register sets  The register section/array consists completely of circuitry used to temporarily store data or program codes until they are sent to the ALU or to the control section or to memory.  The number of registers are different for any particular CPU and the more register a CPU have will result in easier programming tasks.  Registers are normally measured by the number of bits they can hold, for example, an "8-bit register" or a "32-bit register". 41
  • 42. 7- 42Registers  Use of Registers  Scratchpad for currently executing program  Holds data needed quickly or frequently  Stores information about status of CPU and currently executing program  Address of next program instruction  Signals from external devices  General Purpose Registers  User-visible registers  Hold intermediate results or data values, e.g., loop counters  Equivalent to LMC’s calculator  Typically several dozen in current CPUs
  • 43. 43
  • 44. PC Program Counter Register 44
  • 47. STACK Pointer SP Register 47
  • 48. STACK Pointer SP Register 48
  • 51. 51 ATMega32 Programmer Model: Registers (SR) CPU PC ALU registers R1 R0 R15 R2 … R16 R17 … R30 R31 Instruction Register Instruction decoder SREG: I T H S V N CZ $0000 $0001 $0020 General purpose RAM (SRAM) $001F $005F TWBR TWSR SPH SREG ... General Purpose Registers Standard IO Registers $00 $01 $3E $3F $0060 ...... Data Address Space IO Address ... $FFFF SREG: Carry Zero Negative oVerflow Sign N+VHalf carry Temporary Interrupt H S V N CZTI
  • 52. 52 ATMega32 Programmer Model: Registers (SR) CPU PC ALU registers R1 R0 R15 R2 … R16 R17 … R30 R31 Instruction Register Instruction decoder SREG: I T H S V N CZ $0000 $0001 $0020 General purpose RAM (SRAM) $001F $005F TWBR TWSR SPH SREG ... General Purpose Registers Standard IO Registers $00 $01 $3E $3F $0060 ...... Data Address Space IO Address ... $FFFF SREG: Carry Zero Negative oVerflow Sign N+VHalf carry Temporary Interrupt H S V N CZTI Example: Show the status of the C, H, and Z flags after the addition of 0x38 and 0x2F in the following instructions: LDI R16, 0x38 ;R16 = 0x38 LDI R17, 0x2F ;R17 = 0x2F ADD R16, R17 ;add R17 to R16 Solution: 1 $38 0011 1000 + $2F 0010 1111 $67 0110 0111 R16 = 0x67 C = 0 because there is no carry beyond the D7 bit. H = 1 because there is a carry from the D3 to the D4 bit. Z = 0 because the R16 (the result) has a value other than 0 after the addition. Example: Show the status of the C, H, and Z flags after the addition of 0x9C and 0x64 in the following instructions: LDI R20, 0x9C LDI R21, 0x64 ADD R20, R21 ;add R21 to R20 Solution: 1 $9C 1001 1100 + $64 0110 0100 $100 1 0000 0000 R20 = 00 C = 1 because there is a carry beyond the D7 bit. H = 1 because there is a carry from the D3 to the D4 bit. Z = 1 because the R20 (the result) has a value 0 in it after the addition. Example: Show the status of the C, H, and Z flags after the subtraction of 0x23 from 0xA5 in the following instructions: LDI R20, 0xA5 LDI R21, 0x23 SUB R20, R21 ;subtract R21 from R20 Solution: $A5 1010 0101 - $23 0010 0011 $82 1000 0010 R20 = $82 C = 0 because R21 is not bigger than R20 and there is no borrow from D8 bit. Z = 0 because the R20 has a value other than 0 after the subtraction. H = 0 because there is no borrow from D4 to D3. Example: Show the status of the C, H, and Z flags after the subtraction of 0x73 from 0x52 in the following instructions: LDI R20, 0x52 LDI R21, 0x73 SUB R20, R21 ;subtract R21 from R20 Solution: $52 0101 0010 - $73 0111 0011 $DF 1101 1111 R20 = $DF C = 1 because R21 is bigger than R20 and there is a borrow from D8 bit. Z = 0 because the R20 has a value other than zero after the subtraction. H = 1 because there is a borrow from D4 to D3. Example: Show the status of the C, H, and Z flags after the subtraction of 0x9C from 0x9C in the following instructions: LDI R20, 0x9C LDI R21, 0x9C SUB R20, R21 ;subtract R21 from R20 Solution: $9C 1001 1100 - $9C 1001 1100 $00 0000 0000 R20 = $00 C = 0 because R21 is not bigger than R20 and there is no borrow from D8 bit. Z = 1 because the R20 is zero after the subtraction. H = 0 because there is no borrow from D4 to D3.
  • 55. General purpose Registers (R1,R2,R3,….)  Most instructions have direct access to all registers ▫ LD, MUL  Some only operate on R16-R31  ▫ ANDI, CPI, SUBI, MULS  A few operate only on R16:R23  ▫ Special multiply operations  Double word operations operate on register pairs (R24-31)  Most single-byte register or register+immediate operations are single cycle instructions 55
  • 57. 57 AVR Assembler Statement • The Assembler works on source files containing instruction mnemonics, labels and directives. The instruction mnemonics and the directives often take operands. • Code lines should be limited to 120 characters. • Every input line can be preceded by a label, which is an alphanumeric string terminated by a colon. Labels are used as targets for jump and branch instructions and as variable names in Program memory and RAM. • An input line may take one of the five following forms: <label> <opcode> <operand> <;comments> <label> <opcode> <operands> <;comments> <label> <directive> <operands> <;comments> Comments Empty line test: rjmp test ; Infinite loop (Instruction) main: ldi R16, 9 ; store value 9 into register R16 label: .EQU var1=100 ; Set var1 to 100 (Directive) .EQU var2=200 ; Set var2 to 200 ; Pure comment line
  • 58. 58 AVR Assembler Output FilesEDITOR PROGRAM ASSEMBLER PROGRAM DOWNLOAD TO AVR ’s FLASH DOWNLOAD TO AVR’s EEPROM myfile.asm myfile.objmyfile.eep myfile.hex myfile.map myfile.lst
  • 59. 59 AVR Assembler: Example ; Start on the flash ram's address 0 .org 0 000000 e009 main: ldi R16, 9 000001 e016 ldi R17, 6 000002 0f10 add R17, R16 000003 ef2f ldi R18, 255 000004 bb27 out DDRB, R18 000005 bb18 out PORTB, R17 000006 cff9 rjmp main LC Machine code Assembly code Assembly complete, 0 errors, 0 warnings
  • 68. Microcontroller  Microcontrollers are basically used in embedded systems. Computerized or digital control of devices is made plausible with the development of microcontrollers. The development process of microcontroller is similar to that of a microprocessor.  Microcontrollers can be classified based on bus width, memory structure and instruction set. Bus width indicates the size of the data bus. Microcontrollers can be classified as 8 – bit, 16 – bit or 32 – bit based on the bus width. Higher bus widths often result in better performance. 68
  • 69. 69
  • 70. What is the difference between microprocessor, microcontroller and microcomputer...? 70
  • 71. MICROPROCESSOR MICROCONTROLLER 71 Microprocessor assimilates the function of a central processing unit (CPU) on to a single integrated circuit (IC). Microcontroller can be considered as a small computer which has a processor and some other components in order to make it a computer. Microprocessors are mainly used in designing general purpose systems from small to large and complex systems like super computers. Microcontrollers are used in automatically controlled devices.
  • 72. MICROPROCESSOR MICROCONTROLLER 72 Microprocessors are basic components of personal computers. Microcontrollers are generally used in embedded systems Computational capacity of microprocessor is very high. Hence can perform complex tasks. Less computational capacity when compared to microprocessors. Usually used for simpler tasks. A microprocessor based system can perform numerous tasks. A microcontroller based system can perform single or very few tasks.
  • 73. MICROPROCESSOR MICROCONTROLLER 73 Microprocessors have integrated Math Coprocessor. Complex mathematical calculations which involve floating point can be performed with great ease. Microcontrollers do not have math coprocessors. They use software to perform floating point calculations which slows down the device. The main task of microprocessor is to perform the instruction cycle repeatedly. This includes fetch, decode and execute. In addition to performing the tasks of fetch, decode and execute, a microcontroller also controls its environment based on the output of the instruction cycle. In order to build or design a system (computer), a microprocessor has to be connected externally to some other components like Memory (RAM and ROM) and Input / Output ports. The IC of a microcontroller has memory (both RAM and ROM) integrated on it along with some other components like I / O devices and timers.
  • 74. MICROPROCESSOR MICROCONTROLLER 74 The overall cost of a system built using a microprocessor is high. This is because of the requirement of external components. Cost of a system built using a microcontroller is less as all the components are readily available. Generally power consumption and dissipation is high because of the external devices. Hence it requires external cooling system. Power consumption is less. The clock frequency is very high usually in the order of Giga Hertz. Clock frequency is less usually in the order of Mega Hertz.
  • 75. MICROPROCESSOR MICROCONTROLLER 75 Instruction throughput is given higher priority than interrupt latency. In contrast, microcontrollers are designed to optimize interrupt latency. Have few bit manipulation instructions Bit manipulation is powerful and widely used feature in microcontrollers. They have numerous bit manipulation instructions. Generally microprocessors are not used in real time systems as they are severely dependent on several other components. Microcontrollers are used to handle real time tasks as they are single programmed, self sufficient and task oriented devices.
  • 76. Microcontroller Vs Microprocessor  https://www.youtube.com/watch?v=bJY78VIaPCE 76
  • 77. Embedded System Classifications  There are two main families of embedded system platforms:  MICROCONTROLLER Family  High Performance (System On Chip) SOC Platform Family 77
  • 78. 78
  • 79. 79
  • 81. microcontrollers and SoC(System on Chip).  https://www.youtube.com/watch?v=yTKg8LZoIVE 81
  • 82. Conclusion  SOC is the full system, often the computer on a chip, or at least that is the goal. They are very powerful compared to mere micro controllers. SOC may have large amount of memory, peripheral interfaces, radio/wireless connection.May be multicore. Microcontrollers are processor chips with inbuilt peripheral components, ADC,DAC and some memory. Designing a system is easier with these than with a raw microprocessor. Microprocessors are raw processors with minimal ALU+ registers without any peripheral components. You need to connect other chips to make it useful. 82
  • 83. Von Neumann Vs Harvard 83 Earlier microprocessors made use of Von Neumann architecture where the data and instructions (programs) are stored in the same memory. Even though this architecture is simple, there are many draw backs. One of the major drawbacks is that instruction and data cannot be accessed at the same time as they share a single data bus. This often degrades the overall performance of the device. Later, Harvard architecture is introduced which makes use of separate program and data memories with separate buses so that both data and instructions can be accessed at the same time. Later Modified Harvard Architecture is developed in which the program memory is accessed as if it were data memory
  • 84. von Neumann 84 • Same memory holds data, instructions. • A single set of address/data buses between CPU and memory
  • 85. Harvard Architecture  Separate memories for data and instructions.  Two sets of address/data buses between CPU and memory 85
  • 86. Harvard architecture Address bus Data bus Control bus Address bus Data bus Control bus CPU Address bus Data bus Control bus Data Memory Code Memory CPU Code Memory Data Memory Von Neumann architecture Von Neumann vs. Harvard architecture 86
  • 88. Computer Systems Not All Processors Are Created Equal Newer machines use specialized processor chips that have been developed to speed up the processing of data.  CISC - Complex instruction set computer  Large instruction set, many formats  RISC - Reduced instruction set computer  Small instruction set, single or small variations in format  MPP - Massive parallel processing  Many CPUs working in parallel 88
  • 91. At mega 32 Atmel family Flash size 40 pins (4 port * 8) Vref>>>ADC 91
  • 92. AVR different groups 92  Classic AVR e.g. AT90S2313, AT90S4433  Mega e.g. ATmega8, ATmega32, ATmega128  Tiny e.g. ATtiny13, ATtiny25  Special Purpose AVR e.g. AT90PWM216,AT90USB1287
  • 93. 93 ATmega128 ATtiny44 Atmel group Flash =128K Atmel Flash =4K AT90S4433 Atmel Classic group Flash =4KTiny group AVR part numbers
  • 94. 94 ATMega32 Programmer Model: Memory 1. 2KB SRAM – For temporary data storage – Memory is lost when power is shut off (volatile) – Fast read and write 2. 1KB EEPROM – For persistent data storage – Memory contents are retained when power is off (non-volatile) – Fast read; slow write – Can write individual bytes 3. 32KB Flash Program Memory – Used to store program code – Memory contents retained when power is off (non-volatile) – Fast to read; slow to write – Can only write entire “blocks” of memory at a time – organized in 16-bit words (16KWords)
  • 95. 95 ATMega32 Programmer Model: Memory Type Flash RAM EEPROM F_END Size, kB RAMEND Size, kB E_END Size, kB Atmega8 $0FFF 8 $045F 1 $1FF 0.5 Atmega32 $3FFF 32 $085F 2 $3FF 1 Atmega64 $7FFF 64 $10FF 4 $7FF 2 Atmega128 $FFFF 128 $10FF 4 $FFF 4 • AVR microcontrollers are Harvard architecture. This means, that in this architecture are separate memory types (program memory and data memory) connected with distinct buses. Such memory architecture allows processor to access program memory and data memory at the same time. This increases performance of MCU comparing to CISC architecture, where CPU uses same bus for accessing program memory and data memory. • Each memory type has its own address space:
  • 96. 96ATMega32 Programmer Model: Data Memory • GPRs (general purpose registers), • Special Function Registers (SFRs), and • Internal data SRAM. The data memory is composed of three parts:
  • 97. 97ATMega32 Programmer Model:I/O Registers (SFRs) • The I/O memory is dedicated to specific functions such as status register, timers, serial communication, I/O ports, ADC and etc. • Function of each I/O memory location is fixed by the CPU designer at the time of design. (because it is used for control of the microcontroller and peripherals) • AVR I/O memory is made of 8 bit registers. • All of the AVRs have at least 64 bytes of I/O memory location. (This 64 bytes section is called standard I/O memory) • In other microcontrollers, the I/O registers are called SFRs (Special Function Registers) NameAddress I/O Mem. $00 $20 TWBR $01 $21 TWSR $04 $24 ADCL $05 $25 ADCH $02 $22 TWAR $03 $23 TWDR $06 $26 ADCSRA $07 $27 ADMUX $08 $28 ACSR $09 $29 UBRRL $0A $2A UCSRB $0B $2B UCSRA $0C $2C UDR $0D $2D SPCR $0E $2E SPSR $0F $2F PIND$10 $30 DDRD$11 $31 PORTD$12 $32 PINC$13 $33 DDRC$14 $34 PORTC$15 $35 PINB$16 $36 DDRB$17 $37 PORTB$18 $38 PINA$19 $39 DDRA$1A $3A PORTA$1B $3B EECR$1C $3C EEDR$1D $3D EEARL$1E $3E EEARH$1F $3F SPDR NameAddress I/O Mem. NameAddress I/O Mem. UBRRC $20 $40 UBRRH $21 $41 WDTCR $22 $42 ASSR $23 $43 OCR2 $24 $44 TCNT2 $25 $45 TCCR2 $26 $46 ICR1L $27 $47 ICR1H $28 $48 OCR1BL $29 $49 OCR1BH OCR1AH$2B $4B SFIOR$30 $50 OCDR $31 $51 OSCCAL $32 $52 TCCR0$33 $53 MCUCSR$34 $54 MCUCR$35 $55 TWCR$36 $56 SPMCR$37 $57 TIFR$38 $58 TIMSK$39 $59 TCNT1L$2C $4C TCNT1H$2D $4D TCCR1B$2E $4E TCCR1A$2F $4F TCNT0 $3A $5A GICR$3B $5B OCR0$3C $5C SPL$3D $5D SPH$3E $5E GIFR OCR1AL$2A $4A SREG$3E $5E
  • 99. 99 ATMega32 Pin out & Descriptions These pins are used to connect external crystal or RC oscillator Provides supply voltage to the chip. It should be connected to +5 Supply voltage for ADC and portA. Connect it to VCC Clears all the registers and restart the execution of program Reference voltage for ADC Port APort B Port D Port C
  • 100. 100 ATMega32 Pin out & Descriptions Mega32/Mega16 (XCK/T0) PB0 (T1) PB1 (INT2/AIN0) PB2 (OC0/AIN1) PB3 (SS) PB4 (MOSI) PB5 (MISO) PB6 (SCK) PB7 RESET VCC XTAL2 GND XTAL1 (RXD) PD0 (TXD) PD1 (INT0) PD2 (INT1) PD3 (OC1B) PD4 (OC1A) PD5 (ICP) PD6 PA0 (ADC0) PA1 (ADC1) PA2 (ADC2) PA3 (ADC3) PA4 (ADC4) PA5 (ADC5) PA6 (ADC6) PA7 (ADC7) AREF AGND PC7 (TOSC2) AVCC PC6 (TOSC1) PC5 (TDI) PC4 (TDO) PC3 (TMS) PC2 (TCK) PC1 (SDA) PC0 (SCL) PD7 (OC2) DDRA PORTA PINA DDRB PINB PORTB DDRC PORTC PINC
  • 101. 101 ATMega32 Pin out & Descriptions
  • 111. 111 ATMega32 Elementary I/O: LEDs • LEDs must be connected the correct way round, the diagram may be labeled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The cathode is the short lead and there may be a slight flat on the body of round LEDs. If you can see inside the LED the cathode is the larger electrode (but this is not an official identification method). • LEDs can be damaged by heat when soldering, but the risk is small unless you are very slow. No special precautions are needed for soldering most LEDs. • LEDs are available in red, orange, amber, yellow, green, blue and white. Blue and white LEDs are much more expensive than the other colors. The color of an LED is determined by the semiconductor material, not by the coloring of the 'package' (the plastic body). An LED is a semiconductor device that converts electrical energy directly into a discrete color of light
  • 112. 112 ATMega32 Elementary I/O: LEDs • Never connect an LED directly to a battery or power supply! It will be destroyed almost instantly because too much current will pass through and burn it out. • LEDs must have a resistor in series to limit the current to a safe value, for quick testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V or less. • The resistor value, R is given by: • Estimate 1.5 - 2 V voltage drop (VL) • Typically draws 10-20 mA (I) Unless you know what are you doing!
  • 113. 113ATMega32 Elementary I/O: LEDs +5V R output pin 1 +3.2V No current Current light Estimate R = voltage current = 5 – 1.8 – 0.4 13 x 10 -3 = 215 Ω ~ 220 Ω easier to get LED no light +5V +5V R output pin 0 LED +0.4V Turning on an LED Setting the pin to high will not turn ON the LED Setting the pin to low will turn ON the LED
  • 114. DIO_LAB1 114 Write A embedded C Code To toggle 3 Led on sequential way Then start a tick(pulse) by Buzzer then Rerun again Port D pin 5,6,7 as output (LED) Port D pin 4 (Buzzer) step1 step2 step3 step4avr/io.h and util/delay.h
  • 115. DIO_LAB1 Solution: Create ATMEGA32_registers.h to be independent on avr/io.h 115
  • 118. It will be helpful if you learned to Create the ATMEGA32_Registers.h for All Atmega32 Registers 118
  • 120. DIO_Project1 Seven Segment Digital Clock  Write a program for a 2-D Led array (1*2 LCD) using all GPIO pins in Atmeg32, that acts like a real screen. The Screen is divided into two (8*8) frames (characters), and write a two functions that takes a character and print it for each frame. And simulate the project using proteus. the following figure shows one frame 120
  • 121. DIO_Project1 Seven Segment Digital Clock  Say if we want to turn on LED D10 in the matrix, we need to power the PIN14 of module and ground the PIN3 on module. With this the D10 will turn ON. This is shown in the figure below. This should be first check for MATRIX to know everything in order. 121
  • 122. DIO_Project1 Seven Segment Digital Clock  Say if we want to turn on D1, we need to power PIN9 of matrix and ground the PIN13. With that LED D1 will glow. The current direction for this case is shown in below figure. 122
  • 123. DIO_Project1 Seven Segment Digital Clock  Now for the tricky part, consider we want to turn on both D1 and D10 at a time. So we power both PIN9, PIN14 and ground both PIN13, PIN3. With that we will have D2 and D9 ON along with D1 and D10. It’s because they share common terminals. So if we want to turn LEDs along the diagonal, we will be forced to turn ON all the LEDs along the way. This is shown in below figure. 123
  • 124. DIO_Project1 Seven Segment Digital Clock  So to eliminate this problem we will turn only one led on at a time. Say at t=0m SEC, LED D1 is tuned ON. At t = 1m SEC, LED D1 is tuned OFF and LED D2 is turned ON. Again at t=2 m SEC, LED D2 is turned OFF and LED D1 is turned ON. This goes on.  Now the trick is, the human eye cannot capture a frequency more than 30 HZ. That is if a LED goes ON and OFF continuously at a rate of 30HZ or more. The eye sees the LED as continuously ON. However this is not the case. The LED will be constantly turning ON and OFF. This technique is called multiplexing.   By using multiplexing, we will turn only one row at a time, and there will be cycling around the 8 rows continuously. This visualized as a completely turned ON matrix for a naked eye. 124 Multiplexing With very speed To render Each row
  • 125. 125 Led 2 1 0 write embedded C program “up/down binary Counter” By three leds and two push button 0 1 7 …… sw0sw1 DIO_Quiz1
  • 126. 126 I/O: 7-Segment Display  There are applications where you need to display a decimal digit using a seven segment LED display.  The display could represent e.g. the number of times a switch was pressed.  Digits 0-9 and hex A-F can be displayed by giving the proper 7-segment codes q g f e d c b a q g f e d c b a 0 0 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 9 1 1 0 0 1 1 1 2 1 0 1 1 0 1 1 A 1 1 1 0 1 1 1 3 1 0 0 1 1 1 1 b 0 0 1 1 1 1 1 4 1 1 0 0 1 1 0 C 0 1 1 1 0 0 1 5 1 1 0 1 1 0 1 d 1 0 1 1 1 1 0 6 1 1 1 1 1 0 1 E 1 1 1 1 0 0 1 7 0 0 0 0 1 1 1 F 1 1 1 0 0 0 1
  • 127. 127 I/O: 7-Segment Display  Common-anode :  requires VCC  LED ON when Output is LOW.  Common-cathode :  NO VCC ,  LED ON when Output is HIGH.  TTL and CMOS devices are normally not used to drive the common-cathode display directly because of current (mA) requirement. A buffer circuit is used between the decoder chips and common-cathode display
  • 129. 129 I/O: 7-Segment Display A 7-Segment LED could be attached as shown:
  • 131. 131DIO_Lab2 : A 7-segment is connected to PORTA. Write an assembly/embedded C Code to Display 1 on the 7-segment. ATmega32 8 PORTC 0 1 2 3 5 6 4
  • 132. 132DIO_Lab2 Solution: assembly A 7-segment is connected to PORTA. Display 1 on the 7-segment. ATmega32 8 PORTC 0 1 2 3 5 6 4 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 DDRC : PORTC: ; ; DIO_lab2.asm ; ; Author : kkhalil ; ; Replace with your application code LDI R20,0x06 ;R20 = 00000110 (binary) OUT PORTC,R20 ;PORTC = R20 LDI R20,0xFF ;R20 = 11111111 (binary) OUT DDRC,R20 ;DDRC = R20 ;Delay 1 ;cycle latency L1: RJMP L1
  • 133. 133 DIO_Lab3 : Two- digital Display Module 7 Segment Display  DATA LINES: - 7SEG_APORTC .4 - 7SEG_BPORTC .5 - 7SEG_CPORTC .6 - 7SEG_DPORTC .7  DECIMAL POINT: - 7SEG_DPPORTB .0  ENABLE LINES - 7SEG_EN1PORTC .2 - 7SEG_EN2PORTC .3 The trick is, the human eye cannot capture a frequency more than 30 HZ. That is if a LED goes ON and OFF continuously at a rate of 30HZ or more. The eye sees the LED as continuously ON. However this is not the case. The LED will be constantly turning ON and OFF. This technique is called multiplexing.
  • 134. DIO_Lab3 :Two- digital Display Module  Write an embedded C Code to “up Counter” from 0 to 99. 134
  • 135. DIO_Lab3 :Two- digital Display Module  Write an embedded C Code to “up Counter” from 0 to 99. 135
  • 136. DIO_Lab3 :Two- digital Display Module  Write an embedded C Code to “up Counter” from 0 to 99. 136
  • 137. DIO_Lab3 Solution:  Write an embedded C Code to “up Counter” from 0 to 99. 137
  • 139. DIO_Project2 Seven Segment Digital Clock  Our digital clock operates as follows. When the circuit is powered up the clock starts at "00:00:00" for "HH:MM:SS". There are two push-button switches used to set the time. Switch SW1 is for setting the minutes, when this button is pressed the minutes in increase until it reaches 59 then reset and start counting from 0. Switch SW2 is for setting the hours.  All seven segment displays are driven by the same port (PortB). The microcontroller through controls from PortC indicate which seven segment display each digit is displayed on. Note that these Seven Segment Displays are common cathode display. 139
  • 142. References  https://docs.google.com/viewer?a=v&pid=sites&srcid=ZmtlLnV0bS5teXxyaWR6d WFuLXMtd2Vic2l0ZXxneDo2ODU0NzlkM2JkOTg4MjRk  http://www.avrprojects.net/index.php/avr-projects/sensors/38-humidity-and- temperature-sensor-dht11?showall=&start=1  http://www.cse.wustl.edu/~lu/cse467s/slides/dsp.pdf  http://www.avr-tutorials.com/  Microprocessor: ATmega32 (SEE3223-10) http://ridzuan.fke.utm.my/microprocessor-atmega32-see3223-10  http://circuitdigest.com/article/what-is-the-difference-between-microprocessor- and-microcontroller 142
  • 143. 143