lecture 6 microcontrollers in embedded...

28
CENG 314 Embedded Computer Systems Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D. Department of Computer Engineering İzmir Institute of Technology

Upload: others

Post on 19-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

CENG 314Embedded Computer Systems

Lecture 6Microcontrollers in Embedded Systems

Asst. Prof. Tolga Ayav, Ph.D.

Department of Computer Engineeringİzmir Institute of Technology

Page 2: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Another Definition of “Embedded System”

The basic idea of an embedded system is asimple one. If we take any engineering product thatneeds control, and if a computer is incorporated within that product to undertake the control, then we have an embedded system. An embedded system can be defined as:

A system whose principal function is notcomputational, but which is controlled by a computer.

Page 3: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D
Page 4: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D
Page 5: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Computer ReviewCPU+Data Mem.+Prog.Mem.+I/ORISC vs. CISCMemory: Volatile, Non-volatile (ROM)Memory Organization: Von-Neumann vs Harvard

Page 6: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Microcontrollers

Page 7: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Some Microprocessors and Microcontrollers

A gathering of microprocessors and microcontrollers –old and new. From left to right: PIC 12F508, PIC16F84A, PIC 16C72, Motorola 68HC05B16, PIC 16F877, Motorola 68000

Page 8: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Microchip and PIC Microcontroller

The PIC was originally a design of the company General Instruments.It was intended for simple control applications, hence the name –Peripheral Interface Controller.

The simple CPUwas a RISC structure, with a single Working register and just 30 instructions. The output pins could source or sink much more current than most other microprocessors of the time. Already thetrademarks of the PIC were emerging – simplicity, stand-alone, high speed and low cost.General Instruments sold off its semiconductor division to a group of venture capitalists.Microchip stayed firmly entrenched in the 8-bit world. Despite the huge advances that have been made, we can still see features of the old General Instruments microcontroller, even in the most recent designs.

Page 9: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

PIC Microcontrollers Today

Low-costSelf-contained8-bitHarvard structurePipelinedRISCSingle accumulator (the working or W register)Fixed reset and interrupt vectors

Page 10: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Comparison of PIC Families

Page 11: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

The 12 Series familyDesigned for really tiny applicationsVery simple architectureIncludes EEPROM, A/D and RAMSame instruction set with 16C5xx seriesCommonly used in a broad range of applications

Page 12: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

The 12F508 architecture

Page 13: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

The 16 Series FamilyWe will concentrate on 16F84, the more common model.

Page 14: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D
Page 15: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

16F84

Page 16: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Pinout Description

Page 17: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

16F84 Memory Features

Page 18: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

16F84 Program Memory and Stack

Page 19: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Status Register

Page 20: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Register File Map

Page 21: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

16F84 Configuration Word

Page 22: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

EECON Special Function Register (Address

88H)

Page 23: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Register File Summary

Page 24: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Direct/Indirect Addressing

Page 25: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Example Code to Clear Memory

(Direct Addressing)

Page 26: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Clock/Instruction Cycle

Page 27: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

Instruction Pipeline Flow

Page 28: Lecture 6 Microcontrollers in Embedded Systemsweb.iyte.edu.tr/~tolgaayav/courses/ceng314/lecture6A.pdf · Lecture 6 Microcontrollers in Embedded Systems Asst. Prof. Tolga Ayav, Ph.D

External Reset

Power-on resetPOR with discharge diode and protective resistorUser reset button