
- •Table of Contents
- •Preface
- •Additional Material
- •Basic Electronics
- •1.0 The Atom
- •1.1 Isotopes and Ions
- •1.2 Static Electricity
- •1.3 Electrical Charge
- •1.4 Electrical Circuits
- •1.5 Circuit Elements
- •1.6 Semiconductors
- •Number Systems
- •2.0 Counting
- •2.1 The Origins of the Decimal System
- •2.2 Types of Numbers
- •2.3 Radix Representations
- •2.4 Number System Conversions
- •Data Types and Data Storage
- •3.0 Electronic-Digital Machines
- •3.1 Character Representations
- •3.2 Storage and Encoding of Integers
- •3.3 Encoding of Fractional Numbers
- •3.4 Binary-Coded Decimals (BCD)
- •Digital Logic, Arithmetic, and Conversions
- •4.0 Microcontroller Logic and Arithmetic
- •4.1 Logical Instructions
- •4.2 Microcontroller Arithmetic
- •4.3 Bit Manipulations and Auxiliary Operations
- •4.4 Unsigned Binary Arithmetic
- •4.5 Signed Binary Arithmetic
- •4.6 Data Format Conversions
- •Circuits and Logic Gates
- •5.0 Digital Circuits
- •5.1 The Diode Revisited
- •5.2 The Transistor
- •5.3 Logic Gates
- •5.4 Transistor-Transistor Logic
- •5.5 Other TTL Logic Families
- •5.6 CMOS Logic Gates
- •Circuit Components
- •6.0 Power Supplies
- •6.1 Clocked Logic and Flip-flops
- •6.2 Clocks
- •6.3 Frequency Dividers and Counters
- •6.4 Multiplexers and Demultiplexers
- •6.5 Input Devices
- •The Microchip PIC
- •7.0 The PICMicro Microcontroller
- •7.1 PIC Architecture
- •Mid-range PIC Architecture
- •8.0 Processor Architecture and Design
- •8.1 The Mid-range Core Features
- •8.2 Mid-Range CPU and Instruction Set
- •8.3 EEPROM Data Storage
- •8.4 Data Memory Organization
- •8.5 Mid-range I/O and Peripheral Modules
- •PIC Programming: Tools and Techniques
- •9.0 Microchip’s MPLAB
- •9.1 Integrated Development Environment
- •9.2 Simulators and Debuggers
- •9.3 Programmers
- •9.4 Engineering PIC Software
- •9.5 Pseudo Instructions
- •Programming Essentials: Input and Output
- •10.0 16F84A Programming Template
- •10.1 Introducing the 16F84A
- •10.2 Simple Circuits and Programs
- •10.3 Programming the Seven-segment LED
- •10.4 A Demonstration Board
- •Interrupts
- •11.0 Interrupts on the 16F84
- •11.1 Interrupt Sources
- •11.2 Interrupt Handlers
- •11.3 Interrupt Programming
- •11.4 Sample Programs
- •Timers and Counters
- •12.0 The 16F84 Timer0 Module
- •12.1 Delays Using Timer0
- •12.2 Timer0 as a Counter
- •12.3 Timer0 Programming
- •12.4 The Watchdog Timer
- •12.5 Sample Programs
- •LCD Interfacing and Programming
- •13.0 LCD Features and Architecture
- •13.1 Interfacing with the HD44780
- •13.2 HD44780 Instruction Set
- •13.3 LCD Programming
- •13.4 Sample Programs
- •Communications
- •14.0 PIC Communications Overview
- •14.1 Serial Data Transmission
- •14.2 Parallel Data Transmission
- •14.4 PIC Protocol-based Serial Programming
- •14.5 Sample Programs
- •Data EEPROM Programming
- •15.0 PIC Internal EEPROM Memory
- •15.1 EEPROM Devices and Interfaces
- •15.2 Sample Programs
- •Analog to Digital and Realtime Clocks
- •16.0 A/D Converters
- •16.1 A/D Integrated Circuits
- •16.2 PIC On-Board A/D Hardware
- •16.3 Realtime Clocks
- •16.4 Sample Programs
- •Index

186 |
Chapter 9 |
;=====================================================================
;
; Configuration Bits
;
;=====================================================================
_CP_ON |
EQU |
H’000F’ |
_CP_OFF |
EQU |
H’3FFF’ |
_PWRTE_ON |
EQU |
H’3FF7’ |
_PWRTE_OFF |
EQU |
H’3FFF’ |
_WDT_ON |
EQU |
H’3FFF’ |
_WDT_OFF |
EQU |
H’3FFB’ |
_LP_OSC |
EQU |
H’3FFC’ |
_XT_OSC |
EQU |
H’3FFD’ |
_HS_OSC |
EQU |
H’3FFE’ |
_RC_OSC |
EQU |
H’3FFF’ |
Names in the include file are defined in all-capital letters. It is probably a good idea to adhere to this style instead of creating alternate names in lower case. The C-like #include directive is used to refer the .inc files at assembly time, for example:
#include <p16f84a.inc>
9.4.6 Errorlevel Directive
This directive allows controlling the warning and error messages produced at assembly and link times. One particular type of warning can be disturbing: those that refer to bank changes. Applications often turn off bank change related warning with the following line:
errorlevel -302
9.5 Pseudo Instructions
Sometimes a code listing contains instructions that are not part of the standard set for the particular device. The reason this happens is that MPLAB includes a set of p s e u d o - i n s t r u c t i o n s f o r 1 2 - a n d 1 4 - b i t d e v i c e s . Ta b l e 9 . 2 l i s t s t h e s e pseudo-instructions and their standard equivalents:
Table 9.2
PIC Pseudo Instructions
MNEMONIC |
DESCRIPTION |
EQUIVALENT |
STATUS BIT |
|
|
|
|
OPERATION(S) |
CHANGED |
|
|
|
|
|
ADDCF f,d |
Add Carry to File |
BTFSC 3,0 |
Z |
|
|
|
Register |
INCF f,d |
|
ADDDCF f,d |
Add Digit Carry |
|
||
|
|
|||
|
|
to File Register |
BTFSC 3,1 |
Z |
|
|
|
INCF f,d |
|
B |
k |
Branch |
GOTO k |
- |
BC |
k |
Branch on Carry |
BTFSC 3,0 |
|
|
|
|
GOTO k |
- |
(continues)
PIC Programming: Tools and Techniques |
|
|
187 |
||||
|
|
Table 9.2 |
|
|
|
|
|
|
|
PIC Pseudo Instructions |
|
|
|||
|
|
|
|
|
|||
MNEMONIC |
DESCRIPTION |
EQUIVALENT |
STATUS BIT |
||||
|
|
|
OPERATION(S) |
CHANGED |
|||
|
|
|
|
|
|
|
|
BDC k |
|
Branch on Digit |
|
|
|
|
|
|
|
Carry |
BTFSC |
|
3,1 |
|
|
|
|
|
GOTO k |
- |
|
||
BNC k |
|
Branch on No Carry BTFSS 3,0 |
|
|
|||
BNDC |
k |
Branch on No Digit |
GOTO k |
- |
|
||
|
|
|
|
|
|||
|
|
Carry |
BTFSS |
|
3,1 |
|
|
|
|
|
GOTO k |
- |
|
||
BNZ k |
|
Branch on No Zero |
BTFSS |
|
3,2 |
|
|
|
|
|
GOTO k, 2 |
- |
|
||
BZ k |
|
Branch on Zero |
BTFSC 3,2 |
|
|
||
|
|
|
GOTO |
k |
- |
|
|
CLRC |
|
Clear Carry |
BCF |
3,0 |
- |
|
|
CLRDC |
Clear Digit Carry |
BCF |
3,1 |
- |
|
||
CLRZ |
|
Clear Zero |
BCF |
3,2 |
- |
|
|
LCALL |
k |
Long Call |
BCF/BSF 0x0a,3 |
|
|
||
|
|
|
BCF/BSF 0x0a,4 |
|
|
||
|
|
|
CALL k |
|
|
||
LGOTO k |
Long GOTO |
BCF/BSF 0x0a,3 |
|
|
|||
|
|
|
BCF/BSF 0x0a,4 |
|
|
||
|
|
|
GOTO k |
|
|
||
MOVFW f |
Move File to W |
MOVF f,0 |
Z |
||||
NEGF |
f,d |
Negate File |
COMF |
f,1 |
|
|
|
|
|
|
INCF |
f,d |
- |
|
|
SETC |
|
Set Carry |
BSF |
3,0 |
- |
|
|
SETDC |
|
Set Digit Carry |
BSF |
3,1 |
- |
|
|
SETZ |
|
Set Zero |
BSF |
3,2 |
- |
|
|
SKPC |
|
Skip on Carry |
BTFSS |
3,0 |
- |
|
|
SKPDC |
Skip on Digit Carry |
BTFSS |
3,1 |
- |
|
||
SKPNC |
Skip on No Carry |
BTFSC 3,0 |
- |
|
|||
SKPNDC |
Skip on No Digit |
|
|
|
|
|
|
|
|
Carry |
BTFSC |
3,1 |
- |
|
|
SKPNZ |
|
Skip on Non Zero |
BTFSC 3,2 |
- |
|
||
SKPZ |
|
Skip on Zero |
BTFSS |
3,2 |
- |
|
|
SUBCF |
f,d |
Subtract Carry from |
|
|
|
|
|
|
|
File |
BTFSC |
3,0 |
|
|
|
SUBDCF f,d |
Subtract Digit Carry |
DECF |
f,d |
Z |
|||
|
|
|
|
|
|||
|
|
from File |
BTFSC |
3,1 |
|
|
|
|
|
|
DECF |
f,d |
Z |
||
TSTF f |
|
Test File |
MOVF |
f,1 |
Z |
|
We have listed the PIC pseudo-instructions to provide a reference. In our programming we prefer to stay away from using them since they tend to make code less readable. Microchip recommends not using the pseudo-instructions.