PIC Controller

Post on 21-Jan-2016

51 views 0 download

Tags:

description

PIC Controller. Instruction format. RISC (Reduced Instruction Set Computing) or ‘Risk’. Is a CPU design method that gives an instruction set reduced both in size and complexity of addressing modes . Every small operation needs an instruction. - PowerPoint PPT Presentation

Transcript of PIC Controller

PIC Controller

Instruction format

RISC (Reduced Instruction Set Computing) or ‘Risk’ Is a CPU design method that gives an

instruction set reduced both in size and complexity of addressing modes.

Every small operation needs an instruction. Load data from memory to working register,

Add some data, Store the data in to memory – needs 3 instructions.

Ex. ARM, PIC, AVR, SPARC, etc.

CISC (Complex Instruction Set Computing) or ‘Sisk’ Is a microprocessor architecture that gives an

instruction set which can execute many low level operations.

Load data from memory to working register, Arithmetic/Logical operation, Store data into memory – can be done in 1 instruction.

Ex. Intel, AMD, Motorola, etc.

Introduction Instructions do data transfer between the

data memory [SFR (control/configuration registers), GPR, repetitive registers] and working register (W).

Instructions do Arithmetic, logical operations on the data.

Instruction can check the status of each operation and decide the next operation using the status register.

Working Register (Accumulator) Whenever a double operand instruction is

executed, one operand comes from the instruction or from a register. The other operand comes from a register called working register.

This is a special register in CPU (not a part of data memory)

This is the default destination for any instruction.

StatusRegister

StatusRegister

Introduction Each instruction is 14 bit wide

Opcode Specifies instruction type

One or two operands Specifies operation of instruction

Three basic categories Byte oriented Bit oriented Literal and control operations

Inst

ruct

ion

F

orm

ats

OPCODE Field Descriptions

Byte Oriented Operations

Instructions

Assembly Language Each instruction typically consists of an operation or opcode plus zero or more operands.

A label can be specified before each instruction.

Labels are case sensitive and start with an alphabetic or underscore character only.

Assembly Language The instructions must be written in proper

case. The MPASM is case sensitive.

All function registers and their bits are specified in upper case, because upper case is used in the included PIC file.

Use comment for every instruction.

Assembly Language Sample Instruction:

NEXT MOVF FSR,W ;move the contents of FSR to W.

‘NEXT’ is called the Label. ‘MOVF’ is called the Mnemonic. ‘FSR, W’ are called the Operands. ‘;move the contents….’ is the Comment.

Assembly Language Sample Instruction:

_OP1 IORLW 0xFF ;Inclusive OR the contents of W with 1111 1111.

‘_OP1’ is called the Label. ‘IORLW’ is called the Mnemonic. ‘0xFF’ are called the Operands. ‘;Inclusive OR the ….’ is the Comment.

Assembler Directives An assembler directive is a command given

to an assembler. Looks like assembly instructions These directives may do anything from telling

the assembler to include other source files, to allocate memory for constant data, etc.

Specific for each assembler software Ex: RIGHT EQU 1 ;equ is an assembler directive.

Program Structure: All programs must have the following

structure.List p=16f877A ; List directive mentioning the PIC

; Microcontroller part number

#include ‘C:\my_name\pic_lab\P16f877A.inc’

; file having standard definitions of SFR’s of this PIC

ORG 0x20 ; The address 0x20 at which the

; next instruction 'goto' will be stored

GOTO start ; Go to the beginning of main program

start

--------------------------- ;Program Logic

--------------------------- ;Program Logic

END