Basics of PIC and other related articles

PERIPHERAL INTERFACE CONTROLLER (PIC)

INTRODUCTION TO PIC 16F877

To know the basic instruction sets, use the link below.

PIC PROGRAMMING INSTRUCTION SETS

ARITHMETIC AND LOGIC OPERATIONS GROUP

DATA TRANSFER GROUP

BIT OPERATION GROUP INSTRUCTIONS

1) BTFSC

BTFSC is a special type program flow instruction which control the current program flow. Normally BTFSC Test the bit in f, skip if it is zero.

  • Syntax: Label BTFSC f, b
  • Description: Test the specified bit of register f, skip the next instruction if it is zero
  • Operation: Skip the next instruction if f (b) = 0
  • Operand: 0 < f < 127 and 0 < b < 7
  • No. of words: 1
  • No. cycles: 1 or 2 depends on bit value
  • Flags: NIL

2) BTFSS

BTFSS also program flow control instruction. This instruction Test the bit in f, skip if it is one

  • Syntax: Label BTFSS f, b
  • Description: Test the specified bit of register f, skip the next instruction if it is one
  • Operation: Skip the next instruction if f (b) = 1
  • Operand: 0 < f < 127 and 0 < b < 7
  • No. of words: 1
  • No. cycles: 1 or 2 depends on bit value
  • Flags: nil

3) INCFSZ

INCFSZ is a content increment command which Increment f content, skip if it is zero

  • Syntax: Label INCFSZ f, d
  • Description: Increment the f content, skip the next instruction if f is zero
  • Operation: Skip the next instruction if f = zero
  • Operand: (f) + 1 = w if d = 0 and (f) + 1 = f if d = 1
  • No. of words: 1
  • No. cycles: 1 or 2 depends on bit value
  • Flags: nil

4) DECFSZ

DECFSZ command Decrement f content, skip if it is zero

  • Syntax: Label DECFSZ f, d
  • Description: Decrement the f content, skip the next instruction if f is zero
  • Operation: Skip the next instruction if f = zero
  • Operand: (f) – 1 = w if d = 0 and (f) – 1 = f if d = 1
  • No. of words: 1
  • No. cycles: 1 or 2 depends on bit value
  • Flags: nil

5) GOTO

GOTO instruction is used for Jump to specified address locations.

  • Syntax: Label GOTO Label
  • Description: Unconditional jump to specified label
  • Operation: k to PC(10:0), PCLATH(4:3) to PC(12:11)
  • Operand: 0 < k < 2048
  • No. of words: 1
  • No. cycles: 2
  • Flags: nil

6) CALL

CALL command is used for Call the required sub-program or other values.

  • Syntax: Label CALL Label
  • Description: Unconditional call the label
  • Operation: (PC) + 1 to Top of stack, k to PC(10:0), PCLATH(4:3) to PC(12:11)
  • Operand: 0 < k < 2048
  • No. of words: 1
  • No. cycles: 2
  • Flags: nil

7) RETURN

RETURN command is used for Return to main program from any other sub programs

  • Syntax: Label RETURN
  • Description: Unconditional return from subroutine
  • Operation: Top of stack to (PC)
  • Operand: nil
  • No. of words: 1
  • No. cycles: 2
  • Flags: nil

8) RETLW

RETLW is also a return command. By using this command, Return to main program with k in w reg .

  • Syntax: Label RETLW k
  • Description: Unconditional return from subroutine
  • Operation: Top of stack to (PC) and k loaded in w register
  • Operand: 0 < k < 255
  • No. of words: 1
  • No. cycles: 2
  • Flags: nil

9) RETFIE

RETFIE used to return from interrupt routine

  • Syntax: Label RETFIE
  • Description: Unconditional return from subroutine
  • Operation: Top of stack to (PC) and Global Interrupt bit is enabled
  • Operand: nil
  • No. of words: 1
  • No. cycles: 2
  • Flags: nil

Other Instructions in PIC

1)     NOP

NOP command used for denoting No Operation

  • Syntax: Label NOP
  • Description: No operation
  • Operation: nil
  • Operand: nil
  • No. of words: 1
  • No. cycles: 1
  • Flags: nil

2)     CLRWDT

CLRWDT command used for Initialize watchdog time feature .

  • Syntax: Label CLRWDT
  • Description: Watchdog timer and pre-scalar is reset and TO and PD are set
  • Operation: 0 to WDT, 0 to pre-scalar and Status bits TO and PD are set
  • Operand: TO and PD
  • No. of words: 1
  • No. cycles: 1
  • Flags: nil

3)     SLEEP

SLEEP command used for initialize Standby mode.

  • Syntax: Label SLEEP
  • Description: Goes into low consumption, OSC is stopped, Watchdog timer and pre-scalar is reset and TO and PD bits are set
  • Operation: 0 to WDT, 0 to pre-scalar and Status bits, TO is set and PD is reset
  • Operand: TO and PD
  • No. of words: 1
  • No. cycles: 1
  • Flags: nil
Author

Comments are closed.