lecture 1 (course overview and 8051 architecture)...

22
Lecture 1 Course Overview and The 8051 Architecture

Upload: others

Post on 01-May-2020

6 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Lecture 1Course Overview and The 8051 Architecture

Page 2: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

MCUniversity Program Lectures

8051 hit t♦ 8051 architecture♦ System overview of C8051F020♦ 8051 instruction set♦ 8051 instruction set♦ System clock, crossbar and GPIO♦ Assembler directives♦ Programming using C language♦ Interrupts♦ Timer operations and programming♦ Serial communication♦ DAC and comparator♦ ADC

2

Page 3: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Course SyllabusL t T t i lLecture

TopicTutorial

Questions Lab number and Topic Language1 Course overview and 8051 architecture 12 System overview of C8051F020 2 0. Prelab: Working with the tools3 Toolstick Platform Overview3 Toolstick Platform Overview4 8051 Instruction Set 35 System Clock, Crossbar, and GPIO 4 1. Blinky (no timers) Assembly6 Assembler Directives 5 2. 16x16 Multiply Assembly7 Programming using C Language 6 3. Blinky (no timers) C8 Interrupts 79 Timer Operations and Programming 8 4. Blinky (timer with ISR) Assembly

5. Blinky (timer with ISR) and other timer operations C6 Switch debouncing C6. Switch debouncing C

10 Serial Communication 9 7. Serial Communication and LCD C11 DAC and Comparator 8. Analog Comparators C

9. DAC C12 ADC 10 10. ADC C

Lectures and Tutorial questions are based on the “Embedded Programming with Field Programmable

3

Embedded Programming with Field-Programmable Mixed-Signal Microcontrollers” Textbook

Page 4: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Course Goals

At th d f thi h ld b bl t♦ At the end of this course, you should be able to:Understand the architecture of one of the most popular microcontroller (MCU) familiesUse an integrated development environment (IDE) to program and debug an MCUProgram an MCU using Assembly and C languagesg g y g gUnderstand and use peripherals integrated into an MCUInterface an MCU to simple external componentsUnderstand and use interruptsUnderstand and use interruptsUse timers in various modesCommunicate using a serial interfaceUnderstand and use analog to digital converters (ADC), digital to analog converters (DAC) and comparators

4

Page 5: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Course Prerequisites

A i El t i Ci it th t i l d d t di♦ A course in Electric Circuits that includes understanding basic electronic components such as resistors, capacitors, diodes and transistors

♦ A course in basic digital logic design that includes logic d B l i h igates and Boolean arithmetic

♦ Ability to program in a high level programming language♦ Ability to program in a high-level programming language such as C or C++

5

Page 6: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

The 8051 Architecture

♦ Microprocessors and microcontrollers♦ Microprocessors and microcontrollers

♦ The 8051 microcontroller: a brief historyy

♦ Block diagram of the original 8051

♦ Is 8-bit still relevant?

♦ Harvard and von Neumann architectures

♦ Memory organization

♦ Special function registers

6

♦ Special function registers

Page 7: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Microprocessors and Microcontrollers

Mi l CPU♦ Microprocessor: general-purpose CPUEmphasis is on flexibility and performanceGeneric user-interface such as keyboard, mouse, etc.yUsed in a PC, PDA, cell phone, etc.

Mi ll i i l hi♦ Microcontroller: microprocessor + memory on a single chipEmphasis is on size and cost reductionThe user interface is tailored to the application, such as the buttons pp ,on a TV remote controlUsed in a digital watch, TV remote control, car and many common day-to-day appliancesy y pp

7

Page 8: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Terminology

I t t d Ci it (IC) A i i t i d l t i i it th t♦ Integrated Circuit (IC): A miniaturized electronic circuit that consists of semiconductor devices and passive components contained in a packagep g

♦ Central Processing Unit (CPU): This refers to the core of the MCU h dMCU that executes code

♦ Microcontroller Unit (MCU): This is the standard acronym♦ Microcontroller Unit (MCU): This is the standard acronym used for microcontrollers, and refers to the full IC that contains the CPU and peripherals.

♦ “n-bit” – the “n” refers to the data bus width of the CPU, and is the maximum width of data it can handle at a time

8

is the maximum width of data it can handle at a timeExamples: 8-bit MCU, 32-bit MCU

Page 9: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Microcontroller Architectures

Mi t ll hit t f t th i t l h d♦ Microcontroller architecture refers to the internal hardware organization of a microcontroller

♦ Each hardware architecture has its own set of software instructions called assembly language that allows

i f h i llprogramming of the microcontroller

♦ Some of the popular microcontroller architectures♦ Some of the popular microcontroller architecturesIntel 8051Zilog Z80Atmel AVR

9

Page 10: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

The 8051 Microcontroller—A Brief History

I 1980 I t l i t d d th 8051 l t t d ft♦ In 1980, Intel introduced the 8051, relevant today after more than two decades

♦ First device in the MCS-51® family of 8-bit microcontrollers♦ First device in the MCS 51® family of 8 bit microcontrollers♦ In addition to Intel there are other second source suppliers

of the ICs, who make microcontrollers that are compatible i h h 8051 hiwith the 8051 architecture.

♦ In recent years some companies have incorporated many different and additional features into 8051different and additional features into 8051

♦ In 2000, Silicon Laboratories introduced a field programmable, mixed-signal chip (C8051F020) based on the 8051 core CPU

This will be the platform for this course.

10

Page 11: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Is 8-bit Still Relevant?

“ bit” th “ ” f t th d t b idth f th CPU d♦ “n-bit” – the “n” refers to the data bus width of the CPU, and is the maximum width of data it can handle at a time

♦ PCs with 64-bit microprocessors are becoming common♦ PCs with 64 bit microprocessors are becoming common♦ Over 55% of all processors sold per year are 8-bit

processors, which comes to over 3 billion of them per year!*♦ 8-bit microcontrollers are sufficient and cost-effective for

many embedded applications♦ More and more advanced features and peripherals are♦ More and more advanced features and peripherals are

added to 8-bit processors by various vendors♦ 8-bit MCUs are well-suited for low-power applications that

use batteries

*Note: Statistics from Embedded com Article ID# 9900861 Dec 2002

11

*Note: Statistics from Embedded.com Article ID# 9900861, Dec 2002

Page 12: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Example System: RC CarAntenna Antenna

Forward

Reverse

Microcontroller RF Transmitter

Antenna

RF Receiver

Antenna

MicrocontrollerFront Electric

Motor (Left/Right)

Left

Right

Batteries

Voltage Regulator

Power Rear Electric Motor (Fwd/Reverse)

Car lights (LEDs)B tt i

Voltage Regulator

Power

ControlsBatteries Batteries

12

Page 13: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Block Diagram of the Original 8051

/INT0 /INT1

Oth

T0 T1

Timer/Counter(Timer 0 & Timer 1)

4K byte Program Memory (ROM)

128 bytes Data Memory (RAM)

Other interrupts

8051 CPU

I/O ports Serial Port64 K Bus Expansion ControlOscillator

&Timing

P3 P2 P1 P0 (Address/data)

TxD RxD ALE /PSEN From Crystal Oscillator or RC network

13

Page 14: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Block Diagram of the Silicon Labs 8051

14

Page 15: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Harvard and von Neumann Architectures

H d A hit t t f t hit t♦ Harvard Architecture—a type of computer architecture where the instructions (program code) and data are stored in separate memory spacesp y p

Example: Intel 8051 architecture

N A hi h f♦ von Neumann Architecture—another type of computer architecture where the instructions and data are stored in the same memory spacey p

Example: Intel x86 architecture (Intel Pentium, AMD Athlon, etc.)

15

Page 16: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

MCU Fetch-Execute Cycle

♦ Fetch operation retrie es♦ Fetch operation—retrieves an instruction from the location in code memory

i t d t b th

Program Counter

(PC)pointed to by the program counter (PC)

( )

F +

♦ Execute operation—executes the instruction that was fetched during the

Code Memoryet ch

fetch operation. In addition to executing the instruction, the CPU also adds the

CPU

appropriate number to the PC to point it to the next instruction to be fetched.

To other peripherals

16

Page 17: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

8051 and 8052

Th f t t f th 8052 i th t f th 8051♦ The feature set of the 8052 is the superset of the 8051

♦ In addition to all the features of the 8051 the 8052 includes♦ In addition to all the features of the 8051, the 8052 includes128 bytes internal RAM (total of 256 bytes)A third 16-bit timer, with new modes of operationAdditional SFRs to support the third timer

♦ The Silicon Labs C8051F020 builds upon the 8052 and♦ The Silicon Labs C8051F020 builds upon the 8052, and adds further features

♦ The term “8051” is typically used in place of “8052”, and also refers to the 8051 architecture

17

Page 18: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

C8051F020 Data Memory (RAM)

I t l D t M i♦ Internal Data Memory space is divided into three sections

Lower 128U 128Upper 128Special function register (SFR)

Th 384 b t f♦ There are 384 bytes of memory space physically, though the Upper 128 and SFRs share the same addresses from locationsame addresses from location 80H to FFH.

A i t i t ti h ld♦ Appropriate instructions should be used to access each memory block

18

Page 19: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Lower 128—Register Banks and RAM

General Purpose RAM (80 bytes)

Bit-addressable Area (16 bytes)

Register Banks (8 bytes per bank; 4 banks)

19

Page 20: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Special Function Registers (SFRs)

♦ SFRs provide control and data exchange with the microcontroller’s resources and peripherals

♦ Registers which have their byte addresses ending with 0H or 8H are byte- as well as0H or 8H are byte as well as bit- addressable

♦ Some registers are not bit-addressable. These include the stack pointer (SP) and

20

the stack pointer (SP) and data pointer register (DPTR)

Page 21: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

Summary of SFRs♦ Accumulator (ACC) and B register♦ Accumulator (ACC) and B register

ACC (also referred to as A) is used implicitly by several instructionsB is used implicitly in multiply and divide operationsThese registers are the input/output of the arithmetic and logic unit (ALU)

♦ Program status word—PSWShows the status of arithmetic and logical operations using multiple bits such as CarrySelects the Register Bank (Bank 0 - Bank 3)

♦ Stack pointer—SP

♦ Data pointer—DPTR (DPH and DPL)16-bit register used to access external code or data memoryg y

♦ Timer Registers—TH0, TL0, TH1, TL1, TMOD, TCONUsed for timing intervals or counting events

♦ Parallel I/O Port Registers P0 P1 P2 and P3♦ Parallel I/O Port Registers—P0, P1, P2 and P3

♦ Serial Communication Registers—SBUF and SCON

♦ Interrupt Management Registers—IP and IE

21

♦ Interrupt Management Registers IP and IE

♦ Power Control Register—PCON

Page 22: Lecture 1 (Course Overview and 8051 Architecture) Rv01.pptcourses.engr.uky.edu/...1_course_overview_and_8051_architecture_rv… · 1 Course overview and 8051 architecture 1 2 System

www.silabs.com/MCU