Uploaded by Rethabile Letsela

425660106-UNIT-1-PIC-ppt

advertisement
PIC MICROCONTROLLER
(14 ELU 21)
Unit – I
Origin of PIC Micro
Introduction to PIC micro – Origin of PIC micro –
PIC micro family – RISC concepts – Hardware
Description of PIC micro over other micro
controllers.
INTRODUCTION
1. The simplest computer processor is used as the “brain” of
the future system.
2. Depending on the taste of the manufacturer, a bit of memory,
a few A/D converters, timers, input/output lines etc. are
added
3. All that is placed in some of the standard packages.
4. A simple software able to control it all and which everyone
can easily learn about has been developed.
Microprocessor Vs Microcontroller
• Microprocessor - General-purpose microprocessors such as
intel’s X86 family (8086,80286,80386 and the Pentium) or
Motorola’s PowerPC family.
• No RAM, ROM and no I/O ports on the chip itself.
• Commonly referred to as general – purpose microcontrollers
Microcontroller
• It has a CPU in addition to a fixed amount of RAM, ROM
and I/O ports and Timer are all on a single chip.
ORIGIN OF PIC MICRO
• PIC – Peripheral Interface Controller has been coined by
microchip technology in 1989.
• It is a 8-bit microcontroller
• Motorola has been a leader in the 8-bit market with its
MC68HC05 and MC68HC11
• This syllabus focused on PIC 16F877
Wide popularity of these controller has following factors.
• Speed – PIC executes its instruction on 0.2 µs.
• Instruction set simplicity - 35 instruction.
• Integration of operational features – power-on reset, brown
out protection and watchdog timer
• Programmable timer option – 3 timers
• Interrupt control – up to 12 independent interrupt source.
• I/O port
PIC MICRO FAMILY
• PIC microcontroller program ROM
• PIC microcontroller with UV-EPROM
• PIC 18Fxxx with flash
• OTP version of the PIC
• Masked version of PIC
• PIC microcontroller data RAM and EEPROM
• PIC microcontroller I/O pins
• PIC microcontroller peripherals
RISC CONCEPTS
• To increase the processing power of the CPU
1. Increase the clock frequency of the chip.
2. Use Harvard architecture by increasing the no. of buses to
bring more information into the CPU.
3. Change the internal structure of the CPU and use what is
called RISC architecture.
RISC ARCHITECTURE
• Some of the instructions performed complex task.
• Some microprocessor used large no. of instruction and
many of them performed highly complex activities.
• These can be known as CISC (Complex instruction set
computer)
• Many of these complex instructions etched into the brain of
the CPU were never used by programmers and compilers.
• Thereby RISC concepts were developed
Features of RISC
• RISC processors have a fixed instruction size. Instruction
can be 1,2 or even 3 bytes
• It has large no. of registers. All arch have at least 32 reg.
• It have a small instruction set such as ADD, SUB, AND,
OR, CALL.
• 95% of instruction are executed with only one clock cycle.
• RISC processors have separate buses for data and code.
Programming Language
– The lowest-level language is called
Machine languages. It means those
languages which are closer to the
understanding of machine rather than
human beings. A machine language
thus comprises a string of binary O’s
and 1’s.
– Machine language is actually a coded
set of instructions for a particular
CPU (Central Processing Unit), and it
is also known as a machine code.
– A machine language is designed to be
used by a computer without the need
of translation.
Machine Language
• Disadvantage :
1. It is a machine dependent programming language.
Machine dependent means the program designed in one
type of machine or computer could not be run on other
type of computer or machine. So programs designed in
the
machine language in one computer are not easily
portable
to other computers.
2.
It is a very difficult language to understand and learn.
If there is any problem in the program, written in machine
language, then it is very difficult to find out the correct
mistake.
Assembly language
• Assembly language is one level above the machine language.
(Both Machine and Assembly language are considered lowlevel language)
• It uses certain predefined symbolic codes instead of binary
codes. These symbolic codes are called mnemonics.
• Assembly language programs are translated into machine
language by a program called an assembler.
Assembler
Process
High-level language
• High-Level Language overcomes the limitation of writing a
program in Machine and Assembly language as it is difficult
and time consuming.
• In High-Level Language, the programs can be written using
simple English words. Examples of High-Level Language are
BASIC, Fortran, COBOL, C, C++.
• Programs written in high-level languages are translated into
machine language by a compiler.
PIC Assembly Code

Consists of 4 fields:
1
3
operand
2
4
f = Source : name of special-purpose register or RAM variable
F(W) = Destination :
F – destination is f
W – destination is Working Register
Assembler directives
File extensions
LABEL
• A label is used to represent a line or group of code, or a
constant value. It is needed for branching instructions.
• Labels should start in column 1. They may be followed by a
colon (:), space, tab or the end of line.
• Example:
Here
NOP
GOTO Here
Opcode
• This field consists of a symbolic operation code, known as
op-code.
• The opcode describes the operation.
• Symbolic op-codes (known as mnemonic) are translated
into machine language opcode.
• Mnemonics are not case sensitive.
• Example:
BSF
(Bit Set f)
CLRW (Clear W)
Operand Field
• Operands give information to the instruction on the data that
should be used and the storage location for the instruction.
• Operands must be separated from mnemonics by one or more
spaces, or tabs.
• It may has one, two or no operands at all. Multiple operands
must be separated by commas.
• Examples of instructions with different operand fields
NOP
; Instruction with no operand
ANDLW 0x34
; Instruction with one operand
ADDWF FSR,1 ; Instruction with two operand
Comment Field
• Comments are text explaining the operation of a line or lines of
code.
• A semicolon (;) marks the beginning of a comment
• Example:
;Statement line with a comment field
BSF
PortA,0
;set pin 0 of PortA
PIC16F877A Instruction set
• Each microcontroller family has its own set of instructions,
which carry out essentially the same set of operations, but
using different syntax.
• The PIC16F877 only has 35 instructions. Each instruction is
14-bit words.
• This instruction set organized by functional groups is listed in
Table 1.
instruction set by functional
Instruction Type PIC
Definition
Examplesgroups
MOVE
The contents of a register are
copied to another.
REGISTER
Register operations affect only CLRW, CLRF, DECF,
a single register, and all except INCF, SWAPF, COMF,
CLRW (clear W) operate on file RLF, RRF, BCF, BSF
registers.
ARITHMETIC
Addition and subtraction in
binary gives the same result as
in decimal or hex. .
LOGIC
Logic operations are carried out ANDWF, ANDLW,
on bit pairs in two numbers to
IORWF, IORLW, XORWF,
give the result which would be
XORLW
obtained if they were fed to the
corresponding logic gate
TEST, SKIP &
JUMP
make decisions (conditional
program branches) which
depend on some input condition
or the result of a calculation
CONTROL
MOVF, MOVWF,
MOVLW
ADDWF, ADDLW,
SUBWF, SUBLW
BTFSC, BTFSS, DECFSZ,
INCFSZ, GOTO, CALL,
RETURN, RETLW, RETFIE
NOP, SLEEP, CLRWDT
PIC16F877A Instruction set
• Some instructions with alternate result destinations. The default
destination for the result of an operation is the file register, but the
working register W is sometimes an option.
• There are three basic categories:
– Byte-Oriented Instruction:
• F: File Register (or RAM)
• D: Destination
– D=0: Destination  W
– D=1: Destination  File Register
– Bit-Oriented Instruction:
• F: Register File where the Bit is located
• B: Bit Field
– Literal and Control Operation:
• K: 8-bit constant
ADDWF
Download