Download presentation
Presentation is loading. Please wait.
Published byJerome Roy King Modified over 8 years ago
1
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO.5 8051 microcontroller & programming
2
CHAPTER 5:- SYLLABUSDTEL. Topic 1 : Introduction to 8051 microcontroller ; 1 Topic 2: Pin diagram, architecture, features & operation 2 Topic 3: Ports, memory organization, SFR’s, Flags, Counters/Timers, Serial ports 3 Topic 4: Memory Organization & Interfacing 4 2 Topic 5: Addressing Modes, Complete Instruction Set 5
3
CHAPTER-5 SPECIFIC OBJECTIVE / COURSE OUTCOMEDTEL Learn Pin diagram, architecture, features & it’s operation 12 3 The student will be able to: Learn Memory Organization & Interfacing. 3 Understand Ports, memory organization, SFR’s, Flags, Counters/Timers, Serial ports of 8051 4 Learn addressing Modes, Complete Instruction Set for programming
4
LECTURE 38:-DTEL 4 4 Figure 5.1: 80C51 Block Diagram 80C51 Microcontroller
5
LECTURE 38DTEL Figure 5.2: Architecture of 80C51 Microcontroller 5 5 80C51 Microcontroller
6
DTEL 6 THANK YOU LECTURE 38:-
7
LECTURE 39:-DTEL 7 7 Figure 5.3: 80C51 Memory Organization 80C51 Microcontroller
8
LECTURE 39:-DTEL 8 8 8051 Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits –i.e. addresses for only 256 bytes! –PC is 16 bits (up to 64K program memory) –DPTR is 16 bits (for external data - up to 64K) C types –char - 8 bits<-- use this if at all possible! –short - 16 bits int - 16 bits –long -32 bits float -32 bits C standard signed/unsigned 80C51 Microcontroller
9
LECTURE 39:-DTEL 9 9 Accessing External Memory 80C51 Microcontroller
10
LECTURE 39DTEL 10 Program Memory Program and Data memory are separate Can be internal and/or external –20K internal flash for the Atmel controller Read-only –Instructions –Constant data char code table[5] = {‘1’,‘2’,‘3’,‘4’,‘5’} ; –Compiler uses instructions for moving “immediate” data 80C51 Microcontroller
11
DTEL 11 THANK YOU LECTURE 39:-
12
LECTURE 40:-DTEL 12 External Data Memory External Data - xdata –Resides off-chip –Accessed using the DPTR and MOVX instruction –We will not use xdata –We will use the SMALL memory model all data is on-chip limited to only ~128 bytes of data! 80C51 Microcontroller
13
LECTURE 40DTEL 13 Internal Data Memory Internal data memory contains all the processor state –Lower 128 bytes: registers, general data –Upper 128 bytes: indirectly addressed: 128 bytes, used for the stack (small!) directly addressed: 128 bytes for “special” functions 80C51 Microcontroller
14
LECTURE 40:-DTEL 14 Lower 128 bytes Register banks, bit addressable data, general data –you can address any register! –let the C compiler deal with details (for now) 80C51 Microcontroller Figure 5.8:- Lower 128 bytes RAM direct & indirect addressable area.
15
LECTURE 40:-DTEL 15 Figure 5.9:-Upper 128 bytes, SFR area 80C51 Microcontroller
16
DTEL 16 THANK YOU LECTURE 40:-
17
LECTURE 41:-DTEL 17 PORTS Port 0 - external memory access – low address byte/data Port 2 - external memory access – high address byte Port 1 - general purpose I/O – pins 0, 1 for timer/counter 2 Port 3 - Special features – 0 - RxD: serial input – 1 - TxD: serial output – 2 - INT0: external interrupt – 3 - INT1: external interrupt – 4 - T0: timer/counter 0 external input – 5 - T1: timer/counter 1 external input – 6 - WR: external data memory write strobe – 7 - RD: external data memory read strobe 80C51 Microcontroller
18
LECTURE 41:-DTEL 18 Figure 5.10:-PORTS of 8051 80C51 Microcontroller
19
LECTURE 41:-DTEL 19 PORTS Port 0 - true bi-directional Port 1-3 - have internal pull ups that will source current Output pins: – Just write 0/1 to the bit/byte Input pins : – Output latch must have a 1 (reset state) Turns off the pull down Pull up must be pulled down by external driver – Just read the bit/byte 80C51 Microcontroller
20
LECTURE 41:-DTEL 20 Program Status Word Figure 5.11:- Program Status Word 80C51 Microcontroller
21
DTEL 21 THANK YOU LECTURE 41:-
22
LECTURE 42:-DTEL 22 Instruction Timing One “machine cycle” = 6 states (S1 - S6) One state = 2 clock cycles –One “machine cycle” = 12 clock cycles Instructions take 1 - 4 cycles –e.g. 1 cycle instructions: ADD, MOV, SETB, NOP –e.g. 2 cycle instructions: JMP, JZ –4 cycle instructions: MUL, DIV 80C51 Microcontroller
23
LECTURE 42:-DTEL 23 80C51 Microcontroller Figure 5.12:-Instruction Timing of 8051
24
LECTURE 42:-DTEL 24 TIMERS Base 8051 has 2 timers –we have 3 in the Atmel 89C55 Timer mode –Increments every machine cycle (12 clock cycles) Counter mode –Increments when T0/T1 go from 1 - 0 (external signal) Access timer value directly Timer can cause an interrupt Timer 1 can be used to provide programmable baud rate for serial communications Timer/Counter operation – Mode control register (TMOD) – Control register (TCON) 80C51 Microcontroller
25
LECTURE 42:-DTEL 25 Mode Control Register (TMOD) Modes 0-3 GATE - allows external pin to enable timer (e.g. external pulse) – 0: INT pin not used – 1: counter enabled by INT pin (port 3.2, 3.3) C/T - indicates timer or counter mode 80C51 Microcontroller Figure 5.13:-TMOD register of 8051
26
LECTURE 42:-DTEL 26 Timer/Counter Control Register (TCON) TR - enable timer/counter TF - overflow flag: can cause interrupt IE/IT - external interrupts and type control –not related to the timer/counter 80C51 Microcontroller Figure 5.14:-TCON register of 8051
27
LECTURE 42:-DTEL 27 Timer/Counter Mode 0 & 1 Mode 1 same as Mode 0, but uses all 16 bits 80C51 Microcontroller Figure 5.15: Timer/Counter Mode 0:13 bit counter Mode 1:16 bit counter
28
DTEL 28 THANK YOU LECTURE 42:-
29
LECTURE 43:-DTEL 29 Timer/Counter Mode 2 8-bit counter, auto-reload on overflow 80C51 Microcontroller Figure 5.16: Timer/Counter Mode 2: 8bit auto load
30
LECTURE 43:-DTEL 30 Timer/Counter Mode 3 Applies to Timer/Counter 0 Gives an extra timer 80C51 Microcontroller Figure 5.17: Timer/Counter Mode 3: Two 8 bit counters
31
LECTURE 43:-DTEL 31 Interrupts Allow parallel tasking – Interrupt routine runs in “background” Allow fast, low-overhead interaction with environment – Don’t have to poll – Immediate reaction An automatic function call – Easy to program 8051 Interrupts – Serial port - wake up when data arrives/data has left – Timer 0 overflow – Timer 1 overflow – External interrupt 0 – External interrupt 1 80C51 Microcontroller
32
LECTURE 43:-DTEL 32 Interrupt Vector For each interrupt, which interrupt function to call In low program addresses – Hardware generates an LCALL to address in interrupt vector – Pushes PC (but nothing else) onto the stack – RETI instruction to return from interrupt 0x00 - Reset PC address 0: 0x03 - External interrupt 0 1: 0x0B - Timer 0 2: 0x13 - External interrupt 1 3: 0x1B - Timer 1 4: 0x23 - Serial line interrupt 80C51 Microcontroller
33
DTEL 33 Chapter 5 Question Bank Draw & explain block diagram of 8051. What are the salient features of microcontroller? Write short note on PSW. Explain the various addressing modes of 8051 microcontroller. Write a short note on TCON & TMOD register. Discuss in detail about external memory of 8051 microcontroller. Draw a neat diagram showing external memory connections. Draw associated timing diagram. Explain the memory type supported by 8051 LECTURE 43 :-
34
DTEL 34 Summary 1.8051 microcontroller have following features -4KB program memory on-chip -128 bytes data memory on-chip -four register bank -4 parallel ports with programmable pins & 1 serial port -128 user defined software flags -6 interrupt sources -signed overflow detection & parity computation 2. 8051 is having TMOD 8 bit register to set the timer mode operation 3. 8051 having SFR’s e.g.. TMOD, TCON, SCON, etc. in register bank and each having it’s specific address in internal memory. LECTURE 43:-
35
DTEL 35 THANK YOU LECTURE 43:-
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.