advanced microcontrollers grzegorz budzy ń lecture 1 ... · lecture 1: introduction. plan ... •...

85
Advanced Advanced Microcontrollers Microcontrollers Grzegorz Budzy Grzegorz Budzy ń ń L L ecture ecture 1: 1: Introduction Introduction

Upload: others

Post on 20-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

AdvancedAdvanced MicrocontrollersMicrocontrollers

Grzegorz BudzyGrzegorz Budzyńń

LLectureecture 1:1:IntroductionIntroduction

Page 2: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Plan

• Introduction

• Course requirements

• Work plan for the semester

• First lecture – Basic definitions,

Microcontroller, Microprocessor

Page 3: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Introduction

• What is this course about

• What is the aim of this course

Page 4: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Course requirements• Course consists of:

– Lecture – 2h/week

– Project – 2h/week

• Course ends with an exam

• Course completion requires passing project

class and the exam

• The exam will be held during examination

period and will be oral

Page 5: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Workplan for the semster• Lecture 1

– Basic definitions. Embedded systems. Main

elements of embedded systems

• Lecture 2

– 8-bit microcontrollers: AVR family. PIC Micro

family

• Lecture 3

– 8-bit/16-bit microcontrollers: 8051 family,

MSP430 family

Page 6: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Workplan for the semster

• Lecture 4

– 32-bit microcontrollers: AVR32 and PIC32 family

• Lecture 5

– 32-bit microcontrollers: ARM family. ARM7,

ARM9, ARM11, Cortex – M, R, A

• Lecture 6

– 32-bit microcontrollers: ARM based

microcontrollers: STM, NXP

Page 7: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Workplan for the semster• Lecture 7

– DSC & PSoC controllers

• Lecture 8

– DSP processors

• Lecture 9,10

– Serial interfaces: USB, RS232, SPI, I2C, CAN

Page 8: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Workplan for the semster• Lecture 11

– ADC and DAC

• Lecture 12,13

– RTOS – introduction, main parameters

• Lecture 14

– RTOS - examples

• Lecture 15

– Methods of interfacing ADC and DAC to advanced

microcontrollers

Page 9: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

• Lecture 1

Embedded systems

Microcontrollers

Page 10: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

Page 11: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

• Embedded system – a system designed to

perform/ control specific function in a

larger design

• Often with real time computing constraints

(i.e. with predictable response)

Page 12: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

Page 13: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

• Because Embedded System has defined

functionality, thus it can be heavily

optimized in order to:

– Minimize total cost

– Maximize performance

– Maximize perfomance/cost ratio

Page 14: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

• Main elements:

– Microcontrollers:

• 8-bit

• 16-bit

• 32-bit

– Digital Signal Processors

• Digital Signal Controllers

– FPGA / ASIC – programmable logic

Page 15: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

• Embedded software architecture:

– Simple control tasks/loops:

• Used for simples applications

• Used mostly for 8-bit and 16-bit constructions

• Efficient (in assembly code even very efficient)

• Difficult to construct for more complicated tasks

Page 16: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems

• Embedded software architecture:

– Interrupt based system:• Most common type of embedded system software

architecture

• Can be very efficient and rapid in developmenteven for quite complicated tasks/devices

• Functionality depends greatly on the usedmicrocontroller :

– Number of serviced interrupt sources

– Interrupt latency

Page 17: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems• Embedded software architecture:

– Simple real-time operating system:

• Very usable for programming different, non-

dependent on themselves tasks

• Very usable for parallel development by a few

programmers

• Timing control & latency control worse than in

simpler systems

• Cooperative or Preemptive multitasking can be

used

Page 18: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Embedded systems• Embedded software architecture:

– Monolithic operating system:

• Large kernel gives programmers an environment

similar to a desktop operating systems like MS

Windows (WinCE, Win 8 RT), Linux or Android

• Usable in the largest applications like GPS or cell

phones

• Hardware layer controlled totally by the system –

applications isolated from the hardware

Page 19: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microcontroller - basics

Page 20: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microcontrollers - basics

• Microcontroller is a combination of a

microprocessor and peripheral blocks like:

– Memory (RAM, ROM, flash)

– Serial port

– Ethernet controllers

– USB controllers

– ADC

– DAC

– etc

Page 21: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microcontrollers - basics

• Microprocessor (CPU) inside a

microcontroller (MCU) is supervising data

transfer berween peripherals over data

buses

• Main advantages of MCUs are:

– High integration scale

– Low cost

Page 22: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,
Page 23: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - operation

Page 24: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - basics

• Microprocessor:

– is a programmable device

– accepts digital input data

– processes the data according to instructions

stored in memory

– provides results as output

– operates on symbols represented in binary

numeral system

Page 25: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - basics

• Main elements:

– Arithmethic Logic Unit

– Status Register

– Stack Pointer

– Program Counter

– Instruction Decoder

– Registers / Scratch Memory

Page 26: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - basics

Page 27: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - ALU• ALU – Arithmetic Logic Unit is the heart of

microprocessor

• Width of A,B and R defines ifmicroprocessor is 8-, 16-, 32- or 64 bits!!!

Page 28: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - ALU• Functionality of ALU depends on the

paticular realisation

• Usually it offers:

– Addition

– Subtraction

– Comparison

– Logical operations

– Multiplication

– Division

Page 29: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – Status register

• Status register – contains various flags

and control bits

• Flags in the register are modified by

different assembly code instructions

Page 30: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – Stack Pointer• The Stack is mainly used:

– for storing temporary data

– for storing local variables

– for storing return addresses after interrupts and

subroutine calls

– The Stack Pointer Register always points to the

top of the Stack

– the Stack is implemented as growing from higher

memory locations to lower memory locations

Page 31: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – Program Counter

• Program Counter (PC) - a special register

holding the address of the instruction

currently being executed

• Program counter is automatically advanced to

point to the next instruction

• in the case of a jump, subroutine call, etc., a

new value will simply be loaded into the

program counter in order to cause a jump

Page 32: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – Instruction decoder

• Instruction decoder fetches instructions

from a proper memory

• In the next cycle the instructions are

decoded and then executed

• For faster execution pipelining is used

Page 33: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – Registers

• Each CPU consists of a certain number of

universal registers

• They are usually used as temporary

storage of data

• In some CPUs instead of registers a

memory is used

• Access to the registers/momey is much

faster than to external memory

Page 34: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – program flow

Page 35: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – program flow

• The program control logic and program-

address generation logic work together to

provide proper program flow

• Normally, the flow of a program is sequential:

– the CPU executes instructions at consecutive

program-memory addresses

– Discontinuities are caused by branches, function

calls or interrupts

Page 36: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – program flow

• Program execution starts from the address

pointed by a special RESET pointer

• Instructions are in a machine code – i.e.

stream of 8-, 16- or 32b long values

• For simplicity assembly code is used:

Page 37: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – memory map

Page 38: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – addressing modes

Page 39: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – addressing modes

• Direct Single Register Addressing

• Direct Register Addressing, Two Registers

• I/O Direct Addressing

• Direct Data Addressing

• Data Indirect with Displacement

• Data Indirect Addressing

• Data Indirect Addressing with Pre-decrement

Page 40: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor – addressing modes

• Data Indirect Addressing with Post-increment

• Program Memory Constant Addressing

• Program Memory Addressing with Post-

increment

• Direct Program Memory Addressing

• Indirect Program Memory Addressing

• Relative Program Memory Addressing

Page 41: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Direct Single Register Addressing

• Very simple, efficient and fast addressing mode

• Usable only for access to register file

Page 42: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Direct Register Addressing, Two Registers

• Very simple, efficient and fast addressing mode

• Usable only for access to register file

Page 43: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

I/O Direct Addressing

• Easy and efficient access to I/O memory

• Access only to limited memory space (6-bit wide)

Page 44: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Direct Data Addressing

• Access to whole memory space

• Instruction takes much more memory

• Instruction decoding lasts long

Page 45: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Data Indirect with Displacement Addressing

• Target address calculated in dependance on the

special – addressing - register (Y or Z)

Page 46: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Data Indirect Addressing

• Target address take from the special –

addressing - register (X, Y or Z)

Page 47: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Data Indirect Addressing with Pre-decrement

• The content of an addressing register is

decremented before use

• Especially useful in higher level languages

Page 48: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Data Indirect Addressing with Post-increment

• The content of an addressing register is

incremented after use

• Especially useful in higher level languages

Page 49: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Program Memory Constant Addressing

• Access to program memory (loading with LPM

or storing with SPM instructions)

Page 50: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Program Memory Addressing with Post-increment

• Access to program memory (loading with LPM

or storing with SPM instructions)

• Z-register incremented after use

Page 51: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Direct Program Memory Addressing

• Program execution continues at the address

immediate in the instruction word

• Used in JMP and CALL instructions

Page 52: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Indirect Program Memory Addressing

• Program execution continues at address

contained by the Z-register (i.e., the PC is

loaded with the contents of the Zregister)

Page 53: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Relative Program Memory Addressing

• Program execution continues at address PC + k

+ 1. The relative address k is from -2048 to

2047.

Page 54: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor - classifications

Page 55: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• SIMD – ang. Single Instruction Multiple Data

• SISD – ang. Single Instruction Single Data

• MIMD – ang. Multiple Instruction Multiple

Data

• MISD – ang. Multiple Instruction Single Data

Page 56: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• CISC – ang. Complex Instruction Set

Computers

• RISC – ang. Reduced Instruction Set

Computers

Page 57: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• Architectures:

– Von Neuman

– Harvard

– Harvard modified

Page 58: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• SISD features:

– One data stream

– One instruction stream

– Simple construction

– Reduced efficiency

– Very popular

– Most microcontrollers works with this architeture

Sourc

e: [1

]

Page 59: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• MISD features:

– Many instruction streams

– Single data stream

– Parallel operation

– Many units makes the

same operation on one

data

– Rarely used

Sourc

e: [1

]

Page 60: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• SIMD features:

– Single instruction stream

– Many data streams

– Efficient parallel processing

– Different data processed in the

same way

– Used in supercomputers, vector

coprocessors and DSP

Sourc

e: [1

]

Page 61: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• MIMD features:

– Many instruction streams

– Many data streams

– Efficient parallel processing

– Many units operates

independently and

asynchronously

– Used in computation networks

Sourc

e: [1

]

Page 62: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• CISC architecture:

– Large number of instructions

– Small optimization

– Some instructions need many clock cycles

– Existance of complex instructions

– Large number of addressing modes

– Smaller processor clocking as compared to RISC

architecture

Page 63: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• RISC architecture:

– Reduced number of instructions (even below 30)

– Most instructions performed in one clock cycyle

– Instructions simple or very simple

– Limited access to memory

– Large number of auxiliary registers

Page 64: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• Von Neumann architecture

Sourc

e: [2

]

Page 65: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Microprocessor classifications

• Harvard architecture

Sourc

e: [2

]

Page 66: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

8-bits vs 16-bits vs 32-bits

• Some remarks:

– More bits = easier operation with large number of

data

– More bits = less problems with computation

errors

– More bits ≠≠ faster operation

Page 67: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

8-bits vs 16-bits vs 32-bits

• Some remarks:

– Simpler processors can be “overclocked” more

easily

– 32-bit processors are usually faster because that is

necessary

– Smaller processors are very often much more

efficient and simpler for programming then their

“large” brothers

Page 68: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers

• CPUs natively support only integer

numbers – signed or unsigned

• CPU accumulator width defines size of

supported numbers:

– 8b -> [0;0xff] = [0;255]

– 16b -> [0;0xffff] = [0;65535]

– 32b -> [0;0xffffffff] = [0;4294967296]

Page 69: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers

• Signed integers are usually written in U2

code:

i.e.

-1 = 0xff

-128 = 0x80

Page 70: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers

• In CPUs there is problem with non-integer

numbers

• Some CPUs support fractional numbers

• Some have additional coprocessor

(Floating Point Unit – FPU) for real

numbers calculation

Page 71: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers

• Comparison of Integer and Fractional

numbers:

Page 72: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers

• Integer:

– 8-bit (Byte)

– 16-bit (Word)

– 32-bit (Long)

• Float:

– Single precision (float)

– Double precision (double)

Page 73: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers• Single precision:

S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF

0 1 8 9 31

S – sign

E – exponent bits

F - fraction

1272.1)1( −••−=

ESFX

Page 74: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Numbers in microcontrollers• Double precision:

S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

0 1 11 12 63

S – sign

E – exponent bits

F - fraction

10232.1)1( −••−=

ESFX

Page 75: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Endiannes

• Endiannes is the same as byte-order

• Big-endian = MSB goes first

• Little-endian = LSB goes first

Page 76: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking

Page 77: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking

• Benchmarking is used for speed comparation

of microprocessors and microcontrollers

• Comparing microprocessors is difficult

• Comparing microcontrollers is even more

difficult – it is fairly easy to compare cores but

very hard to compare peripherals!!!

Page 78: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking

• Main measures of microcontrollers core speed

are:

– MIPS

– DMIPS

– FLOPS

Page 79: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking - MIPS

• MIPS – Millions of Instructions Per Second

• Simple algorithm usually used – speed of NOP instruction ☺

• Comparison of processors speeds requires thorough analysis.

• The speed of a given CPU is dependent upon many factors:

– the type of instructions being executed,

– the execution order and

– the presence of branch instructions (pipeline!)

Page 80: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking - MIPS• CPU instruction rates are usually different from clock

frequencies

• Each instruction usually require several clock cycles

to complete

• The number of cycles required for instructions to

complete is dependent upon the instruction being

executed

• MIPS can be useful when comparing performance

between processors made from a similar

architecture

Page 81: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking - DMIPS

• DMIPS – another name for Dhrystone typecomputer speed test

• Dhrystone is a synthetic computing benchmark intended to be representative of system (integer) programming

• The algorithm is well documented and can be made to work on almost any system

Page 82: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking - DMIPS

• DMIPS – shortcomings:

– it features unusual code that is not usually

representative of real-life programs

– it is susceptible to compiler optimizations

– Dhrystone's small code size may fit in the

instruction cache of a modern CPU, so that

instruction fetch performance is not rigorously

tested

Page 83: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Benchmarking - FLOPS

• FLOPS - FLoating-point Operations Per Second

• Measure of floating point arithmetic

operation speed of a microcontroller

• Similar to MIPS but for floating point numbers

Page 84: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

Thank you for your attention

Page 85: Advanced Microcontrollers Grzegorz Budzy ń Lecture 1 ... · Lecture 1: Introduction. Plan ... • Courserequirements • Workplan for thesemester • Firstlecture–Basic definitions,

References

[1] www.wikipedia.org

[2] http://www.scribd.com/doc/1532910/Von-Neumann-

Computer-Architecture

[3] www.atmel.com