22
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Embed Size (px)

Citation preview

Page 1: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Microcontroller based system design

Asst. Prof. Dr. Alper ŞİŞMAN

Page 2: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Course Objectives

• to develop an in-depth understanding of – the operation of microprocessors and microcontrollers– C language platform for embedded systems– microcontroller interfacing techniques– The path an embedded system, design&implementation of

embedded systems in both hardware and software

• to be able to use ST32F4 series high performance 32-bit ARM (Advanced RISC Machine) based microcontrollers.

Page 3: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Outline

• Microcontroller basics and programming concepts,basic architecture.

• <Exercise: The compiler and its capabilities, simulation, debugging examples>

• Programming Model, Addressing Modes and Instruction Set

• <Exercise: LED on/off>• Interfacing concepts, IO module• <Exercise: push button,7-segment, keypad connection

and alphanumeric display examples>

Page 4: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

• Timer and ADC modules• <Exercise: Data acquisition and control examples>• The Stack, Subroutines and Interrupts• <Exercise: Use of external and timer interrupts>• Serial communications, Universal async.

Receive/transmit (UART)• <Exercise: An UART application>• Serial communication , I2C and SPI• <Exercise: An I2C application>

Page 5: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Common computer organization (simplified view)

• ALU (Arithmetic Logic Unit) is a circuitry, which is capable of doing various operations (for example ADD, SHIFT, AND, OR, etc) on certain on-chip registers.

• CPU (Central Processing Unit) is the combination of the control logic, associated registers and the arithmetic logic unit.

Page 6: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Block diagram of a typical CPU

Page 7: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

CPU structure

• The main functions are– data transfer– arithmetic and logic operations– decision making (instructional flow control)

• The register array consists of at least one accumulator, program counter and stack pointer

• The control unit controls all the operations in a CPU and basically it puts the CPU in one of the fetch and execution phases

Page 8: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

MemoryInput/Output

(I/O)

ALU

Control

CPU

Page 9: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Computer Buses

• Address bus: carries the address of a unique memory or input/output (I/O) device

• Data bus: carries data stored in memory (or an I/O device) to the CPU or from the CPU to the memory (or I/O device)

• Control bus: is a collection of control signals that coordinate and synchronize the whole system

Page 10: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Buses and common comp. arch.

Page 11: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Memory

• The memory in a computer system stores the data and instructions of the programs.

Adress decoder Storage

Area

Adress bus

Data bus

Other signals (Vcc,Gnd, CS, etc.)

Page 12: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Main memory types

• ROM (read-only memory) – programmed permanently at the factory, cannot be

altered

• RAM (random-access memory) – read and write memory

• EPROM (erasable programmable ROM) – nonvolatile, written electrically but erased optically

• EEPROM (electrically ROM) – nonvolatile, both written and erased electrically

Page 13: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Memory

Page 14: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Operation of CPU

• Fetch cycle (phase): – The CPU puts the address of the instruction to be

executed on the address bus. The address info comes from the program counter (PC) maintained by the control unit.

– The control bus holds the info. for reading the memory location and the data bus holds the instruction from the memory which is stored into the instruction register (IR)

– PC is updated to point to the next instruction.

Page 15: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

• Execute cycle (phase): – Instruction in the IR is decoded – The required data transfer and the required logical and

arithmetic operation are performed– The result is written back either to one of the registers

or memory or I/O device

• Common operations performed in ALU are:– addition, subtraction, – logical AND, OR, XOR, NOT– increment, decrement, shift, clear, etc.

Page 16: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN
Page 17: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Detailed operation

Page 18: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Microcomputer/Microcontroller• CPU on a single ICmicroprocessor (µP).• the terms CPU, µP and MPU (microprocessor unit)

are synonymous.• CPU is the combination of the ALU and control

unit of any computer.• When the CPU is a single IC; it is called a µP and

is also referred to as the MPU.• When the MPU‘s connected to memory and I/O,

the arrangement becomes a MICROCOMPUTER.• What is microcontroller?: A microcontroller unit

(MCU) contains an MPU, memory, and I/O circuitry on a single chip.

Page 19: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Microprocessor vs microcontroller • Microprocessors: high performance, generalpurpose “brains” for PCs and workstations– Instruction decode and control, arithmetic/logic operations,

registers, timing, external control– Typical cost: $75 -- $500– Annual demand: 10s of millions

• Microcontrollers: devices with high levels of integration for embedded control– Microprocessor functions plus on-chip memory and

peripheral functions (e.g. ports, timers)– "Swiss army knife" of microprocessor technology– Typical cost: $1-- $25– Annual demand: billions!

Page 20: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Bottom-Up wiev of microcontroller systems

Page 21: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

Embedded System• The majority of microcontrollers in use today are

embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for computer systems. These are called embedded system.

• Typical input and output devices include switches, relay, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc.

• Embedded systems usually have no keyboard, screen, disks, printers, or other recognizable I/O devices of a personal computer, and may lack human interaction devices of any kind.

Page 22: Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN

ARM based MCUs