microprocessors & microcontrollers mehdi dehghani
TRANSCRIPT
Microprocessors &
microcontrollers
Mehdi Dehghani
Topics
What is a Computer?Some Kinds of memoryMemory addressingMicroprocessorsMicrocontrollerMicrocontroller Vs MicroprocessorsWhat is AVR ?Why we study AVR?AVR; Pins & PortsProgramming and ProgrammerProgramming environmentProgramming languages
TopicsWriting the simple program and execute it.Adding the buttonWhat's debouncing? How could it solvedTimer & counters in AVRAbout interruptsPower suppliesIntroduction to LCDWriting programs and passing strings to LCDDisplay numeric in LCDIntroduction to adsProgramming ads using interruptsIntroduction to PWM
4
What is a Computer?
• Central Processing Unit (CPU) – Executes the programs
• Primary Memory – Stores programs and data
• Input / Output Devices – Allow CPU to communicate with external
hardware • System Bus
– Connects everything together – Address, Data, Control signals
5
6
Processor
8088
8086
80286
80386dx
80486
80586/Pentium (Pro)
Data Bus
8
16
16
32
32
64
Address Bus
20
20
24
32
32
32
Max Addressable Memory
1,048,576 (1Mb)
1,048,576 (1Mb)
16,777,21 (16Mb)
4,294,976,296 (4Gb)
4,294,976,296 (4Gb)
4,294,976,296 (4Gb)
7
Intel
8
Intel
9
Data Bus
Address Bus
Control Bus
Processor
Memory I/O
(BUS CPU)
Address Busprovides a memory address to system memory and I/O address to system I/O devicesData Bus transfers data between the microprocessor and the memory and I/O attached to the systemControl Busprovides control signals that cause memory or I/O devices to perform a read or write operation
10
CPU
General-Purpose Micro-processor
RAM ROM I/O Port
TimerSerial COM Port
Data Bus
Address Bus
General-purpose microprocessor:
• CPU for Computers• Commonly no RAM, ROM, I/O on CPU chip itself
Many chips on motherboard
ACOE343 - Real-Time Embedded Processor Systems - Frederick University
11
Components of a microprocessor/controller
• CPU: Central Processing Unit• I/O: Input /Output• Bus: Address bus & Data bus• Memory: RAM & ROM• Timer• Interrupt• Serial Port• Parallel Port
ACOE343 - Real-Time Embedded Processor Systems - Frederick University
12
RAM ROM
I/O Port
TimerSerial COM Port
Microcontroller
CPU
• A single-chip computer• On-chip RAM, ROM, I/O ports...• Example:Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X
A single chip
Microcontroller :
Microprocessor vs. Microcontroller• Microprocessor • CPU is stand-alone, RAM, ROM, I/O, timer are separate• designer can decide on the amount of ROM, RAM and I/O ports.• More power• versatility • general-purpose
Microcontroller• CPU, RAM, ROM, I/O
and timer are all on a single chip
• fix amount of on-chip ROM, RAM, I/O ports
• for applications in which cost, power and space are critical
• Less applications
14
Data Type
• Numbers – bit (e.g., 1) ; nibble = 4 bits – DB: byte = octet = 8 bits – DW: Word = 2 bytes = 16 bits– DD: DoubleWord = 4 bytes = 32 bits
15
Memory Data Types
• Text – Letters and characters (7-bit ASCII
standard), e.g., 'A'=65=0x41 – Extended ASCII (8-bit) allows for extra 128
graphics/symbols) – Collection of characters = Strings – Collection of Strings = Documents
Data Type
16
Data Type
17
Computer System
DiskDisk
Memory-I/O busMemory-I/O bus
ProcessorProcessor
CacheCache
MemoryMemoryI/Ocontroller
I/Ocontroller
I/Ocontroller
I/Ocontroller
I/Ocontroller
I/Ocontroller
DisplayDisplay NetworkNetwork
Reg
18
19
Memory Arrays
Random Access Memory Serial Access Memory Content Addressable Memory(CAM)
Read/Write Memory(RAM)
(Volatile)
Read Only Memory(ROM)
(Nonvolatile)
Static RAM(SRAM)
Dynamic RAM(DRAM)
Shift Registers Queues
First InFirst Out(FIFO)
Last InFirst Out(LIFO)
Serial InParallel Out
(SIPO)
Parallel InSerial Out
(PISO)
Mask ROM ProgrammableROM
(PROM)
ErasableProgrammable
ROM(EPROM)
ElectricallyErasable
ProgrammableROM
(EEPROM)
Flash ROM
20
Speed & cost
21
Mask ROM
22
What is the difference between flash memory and EEPROM?
Best Answer
EEPROM is an older, more reliable technology. It is somewhat slower than Flash.
Flash and EEPROM are very similar, but there is a subtle difference. Flash and EEPROM both use quantum cells to trap electrons. Each cell represents one bit of data. The presence - or absence - of electrons in a cell indicates whether the bit is a 1 or 0.
The cells have a finite life - every time a cell is erased, it wears out a little bit. In EEPROM, cells are erased one-by-one. The only cells erased are those which are 1 but need to be zero. (Writing a 1 to a cell that's 0 causes very little wear, IIRC)
In Flash, a large block is erased all at once. In some devices, this "block" is the entire device. So in Flash, cells are erased whether they need it or not. This cuts down on the lifespan of the device, but is much, much faster than the EEPROM method of going cell-by-cell.
(flash Vs EEPROM)
23
RAM
24
Semiconductor Memory Types
• RAM: the stored data is volatile
– DRAM• A capacitor to store data, and a transistor to access the capacitor• Need refresh operation• Low cost, and high density it is used for main memory
– SRAM• Consists of a latch• Don’t need the refresh operation• High speed and low power consumption it is mainly used for cache
memory and memory in hand-held devices
RAM
25
Static RAM (SRAM)• Fast
– ~4 nsec access time• Persistent
– as long as power is supplied– no refresh required
• Expensive – ~$100/MByte– 6 transistors/bit
• Stable– High immunity to noise and environmental disturbances
• Technology for caches
SRAM
26
Dynamic RAM (DRAM)• Slower than SRAM
– access time ~60 nsec
• Nonpersistant – every row must be accessed every ~1 ms (refreshed)
• Cheaper than SRAM – ~$1.50 / MByte– 1 transistor/bit
• Fragile– electrical noise, light, radiation
• Workhorse memory technology
DRAM
27
Memory Address Pins
28
memory & data size
29
بیتی16بانک های حافظه در میکرو پروسسور های
30
بیتی32بانک های حافظه در میکرو پروسسور های
داشتن CPU یک تعداد 16با چه و حافظه خانه تعداد چه آدرس میکند؟ I/Oخط دهی آدرس را
31
بیتی32بانک های حافظه در میکرو پروسسور های
سوال امتحان :
خط آدرس چه تعداد خانه حافظه را آدرس دهی میکند؟16 با داشتن CPU یک
216 = 26 X 210 = 64 X 1K = 64K
سوال امتحان :
بیتی 8؟چند بیتی است CPUدیتا دارد این خط CPU 8 یک
32
If a memory chip has 13 address pins (A0..A12), then it has:
213 = 23 X 210 = 8 X 1K = 8K
If a memory chip has 4K locations, then it should have N pins:
4K = 4 X 1K = 22 X 210 = 212 N=12
address pins (A0..A11)
Memory Decoder
33
000
001
002
003
HexMemoryContents
3FC
3FD
3FE
10011001
00111000
00-0000-0000
00-0000-0001
00-0000-0010
00-0000-0011
11-1111-1100
11-1111-1101
11-1111-1110
11-1111-1111 3FF
11001001
00111011
01101000
10111001
00110100
00011000
Memory Address
Binary
1024 X 8 (or 1KX8) Memory
Memory Decoder
34
Memory Decoder ( 74138 Decoder 3 TO 8 )
35
Memory Decoder ( 74139 2 * Decoder 2 TO 4 )
36
Memory Decoder
وصل وصل کنید.CPU به 1FFF – 1000 را در آدرس EPROM - 4 Kسوال امتحان : یک عدد
100
0