Micro controllers A self-contained system in which a processor, support, memory, and input/output...

31
Micro controllers • A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Transcript of Micro controllers A self-contained system in which a processor, support, memory, and input/output...

Page 1: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Micro controllers

• A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Page 2: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Types of Microcontrollers

• Embeded (Self-contained) 8 bit

• 16-32 bit

• Digital Signal Processors

Page 3: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Basic Features

• Processor reset

• Device clocking

• Central processor

• Program and Variable Memory (RAM)

• I/O pins

• Instruction cycle timers

Page 4: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

More Sophisticated Features

• Built-in monitor/debugger program• Interrupt capability• Analog I/O (PWM and variable dc I/O• Serial I/O (synchronous, a synchronous)• Parallel I/O (including direct interface to a

master processor• External memory interface

Page 5: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Processor Architecture

• CISCLarge amount of instructions each carrying out

a different permutation of the same operationFunctionality of the instructions is more

dependent upon the processor’s designer

Page 6: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Processor Architecture

• RISCFundamental set of instructions More control for users to design their

own operations

Page 7: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Processor Architecture

• Princeton (Van Neumann) architectureCommon memory for program and data Simple chip designExecution of an instruction can take

multiple cycles

Page 8: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Processor Architecture

• Harvard architectureSeparate memory space program and

dataInstructions are executed in one cycleEasier timing of loops and delays

Page 9: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Processor Architecture

• Princeton architecture example

Mov acc, reg

Cycle 1 Read instruction

Cycle 2 Read data out of Ram and

put into

Acc

Page 10: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Processor Architecture

• Harvard architecture exampleMov acc, reg

Cycle 1 Execute previous instruction

Read “move acc, reg”

Cycle 2 Execute “move acc, reg” instruction

Page 11: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Microchip PIC Micro controllers

(PIC 16F877)

Page 12: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Hardware Architecture

• PIC Microcontrollers have following main features:

• Harvard Architecture• RISC Feature• CPU pipelines instruction fetching and

execution in order to achieve an execution of one instruction at every cycle

Page 13: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 14: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 15: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Memory Organization

• Program Memory

• Register File Memory

Page 16: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Program Memory

• Used for storing compiled code

• Each location is 14 bits long

• Every instruction is coded as a 14 bit word

• Addresses H’000’ and H’004’ are treated in a special way

• PC can address up to 8K addresses

Page 17: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 18: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 19: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Register File Memory

• Consist of 2 ComponentsGeneral Purpose Register (GPR) Files

(RAM)Special Purpose Register (SPR) files

• This portion of memory is separated into banks of 128 bytes long

Page 20: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 21: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Register Addressing Modes

• There are 3 types of addressing modes in PIC

Immediate Addressing Movlw H’0F’

Direct AddressingIndirect Addressing

Page 22: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Direct Addressing

• Uses 7 bits of 14 bit instruction to identify a register file address

• 8th and 9th bit comes from RP0 and RP1 bits of STATUS register.

• Exp:

Z equ D’2’

btfss STATUS, Z

Page 23: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 24: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Indirect Addressing

• Full 8 bit register address is written the special function register FSR

• INDF is used to get the content of the address pointed by FSR

• Exp : A sample program to clear RAM locations H’20’ – H’2F’ .

Page 25: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 26: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Some CPU Registers

• STATUS

• PC

• W

• PCL

• PCLATH

Page 27: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 28: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Instruction Set

• Every Instruction is coded in a 14 bit word

• Each instruction takes one cycle to execute

• Only 35 instructions to learn (RISC)

Page 29: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Instruction Set

• Uses 7 bits of 14 bit instruction to identify register file address

• For most instructions, W register is used as a source register

• The result of an operation can be stored back to the W register or back to source register

Page 30: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Page 31: Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.

Some Arithmetic Operations

• addwf FSR, w ; Add w to FSR and put result in w

• iorwf TMR0, f ; Inclusive OR w with TMR0 and store result in TMR0

• addwf reg ; Add content of the reg to content of the w and store the result back

into reg (source)