Data Sheet High-Performance, Enhanced Flash Microcontrollers phần 7 pptx

33 216 0
Data Sheet High-Performance, Enhanced Flash Microcontrollers phần 7 pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

PIC18FXX2 19.2.2 WDT POSTSCALER The WDT has a postscaler that can extend the WDT Reset period The postscaler is selected at the time of the device programming, by the value written to the CONFIG2H configuration register FIGURE 19-1: WATCHDOG TIMER BLOCK DIAGRAM WDT Timer Postscaler 8 - to - MUX WDTEN Configuration bit WDTPS2:WDTPS0 SWDTEN bit WDT Time-out Note: TABLE 19-2: WDPS2:WDPS0 are bits in register CONFIG2H SUMMARY OF WATCHDOG TIMER REGISTERS Name CONFIG2H RCON WDTCON Bit Bit Bit Bit Bit Bit Bit Bit — — — — WDTPS2 WDTPS2 WDTPS0 WDTEN IPEN — — RI TO PD POR BOR — — — — — — — SWDTEN Legend: Shaded cells are not used by the Watchdog Timer DS39564C-page 204 © 2006 Microchip Technology Inc PIC18FXX2 19.3 Power-down Mode (SLEEP) Power-down mode is entered by executing a SLEEP instruction If enabled, the Watchdog Timer will be cleared, but keeps running, the PD bit (RCON) is cleared, the TO (RCON) bit is set, and the oscillator driver is turned off The I/O ports maintain the status they had before the SLEEP instruction was executed (driving high, low or hi-impedance) For lowest current consumption in this mode, place all I/O pins at either VDD or VSS, ensure no external circuitry is drawing current from the I/O pin, power-down the A/D and disable external clocks Pull all I/O pins that are hi-impedance inputs, high or low externally, to avoid switching currents caused by floating inputs The T0CKI input should also be at VDD or VSS for lowest current consumption The contribution from on-chip pull-ups on PORTB should be considered The MCLR pin must be at a logic high level (VIHMC) 19.3.1 WAKE-UP FROM SLEEP The device can wake-up from SLEEP through one of the following events: External RESET input on MCLR pin Watchdog Timer Wake-up (if WDT was enabled) Interrupt from INT pin, RB port change or a Peripheral Interrupt The following peripheral interrupts can wake the device from SLEEP: PSP read or write TMR1 interrupt Timer1 must be operating as an asynchronous counter TMR3 interrupt Timer3 must be operating as an asynchronous counter CCP Capture mode interrupt Special event trigger (Timer1 in Asynchronous mode using an external clock) MSSP (START/STOP) bit detect interrupt MSSP transmit or receive in Slave mode (SPI/I2C) USART RX or TX (Synchronous Slave mode) A/D conversion (when A/D clock source is RC) 10 EEPROM write operation complete 11 LVD interrupt External MCLR Reset will cause a device RESET All other events are considered a continuation of program execution and will cause a “wake-up” The TO and PD bits in the RCON register can be used to determine the cause of the device RESET The PD bit, which is set on power-up, is cleared when SLEEP is invoked The TO bit is cleared, if a WDT time-out occurred (and caused wake-up) When the SLEEP instruction is being executed, the next instruction (PC + 2) is pre-fetched For the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled) Wake-up is regardless of the state of the GIE bit If the GIE bit is clear (disabled), the device continues execution at the instruction after the SLEEP instruction If the GIE bit is set (enabled), the device executes the instruction after the SLEEP instruction and then branches to the interrupt address In cases where the execution of the instruction following SLEEP is not desirable, the user should have a NOP after the SLEEP instruction 19.3.2 WAKE-UP USING INTERRUPTS When global interrupts are disabled (GIE cleared) and any interrupt source has both its interrupt enable bit and interrupt flag bit set, one of the following will occur: • If an interrupt condition (interrupt flag bit and interrupt enable bits are set) occurs before the execution of a SLEEP instruction, the SLEEP instruction will complete as a NOP Therefore, the WDT and WDT postscaler will not be cleared, the TO bit will not be set and PD bits will not be cleared • If the interrupt condition occurs during or after the execution of a SLEEP instruction, the device will immediately wake-up from SLEEP The SLEEP instruction will be completely executed before the wake-up Therefore, the WDT and WDT postscaler will be cleared, the TO bit will be set and the PD bit will be cleared Even if the flag bits were checked before executing a SLEEP instruction, it may be possible for flag bits to become set before the SLEEP instruction completes To determine whether a SLEEP instruction executed, test the PD bit If the PD bit is set, the SLEEP instruction was executed as a NOP To ensure that the WDT is cleared, a CLRWDT instruction should be executed before a SLEEP instruction Other peripherals cannot generate interrupts, since during SLEEP, no on-chip clocks are present © 2006 Microchip Technology Inc DS39564C-page 205 PIC18FXX2 WAKE-UP FROM SLEEP THROUGH INTERRUPT(1,2) FIGURE 19-2: Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 OSC1 TOST(2) CLKO(4) INT pin INTF flag (INTCON) Interrupt Latency(3) GIEH bit (INTCON) Processor in SLEEP INSTRUCTION FLOW PC Instruction Fetched Instruction Executed Note 1: 2: 3: 4: PC PC+2 PC+4 PC+4 Inst(PC) = SLEEP Inst(PC + 2) SLEEP Inst(PC + 2) Dummy Cycle 0008h 000Ah Inst(0008h) Inst(PC + 4) Inst(PC - 1) PC + Inst(000Ah) Dummy Cycle Inst(0008h) XT, HS or LP Oscillator mode assumed GIE = '1' assumed In this case, after wake-up, the processor jumps to the interrupt routine If GIE = '0', execution will continue in-line TOST = 1024 TOSC (drawing not to scale) This delay will not occur for RC and EC Osc modes CLKO is not available in these Osc modes, but shown here for timing reference DS39564C-page 206 © 2006 Microchip Technology Inc PIC18FXX2 19.4 Program Verification and Code Protection Each of the five blocks has three code protection bits associated with them They are: The overall structure of the code protection on the PIC18 FLASH devices differs significantly from other PICmicro devices • Code Protect bit (CPn) • Write Protect bit (WRTn) • External Block Table Read bit (EBTRn) The user program memory is divided into five blocks One of these is a boot block of 512 bytes The remainder of the memory is divided into four blocks on binary boundaries Figure 19-3 shows the program memory organization for 16- and 32-Kbyte devices, and the specific code protection bit associated with each block The actual locations of the bits are summarized in Table 19-3 FIGURE 19-3: CODE PROTECTED PROGRAM MEMORY FOR PIC18F2XX/4XX MEMORY SIZE/DEVICE 16 Kbytes (PIC18FX42) 32 Kbytes (PIC18FX52) Boot Block Boot Block 000000h 0001FFh Block Block Code Protection Controlled By: Address Range Block CPB, WRTB, EBTRB 000200h CP0, WRT0, EBTR0 001FFFh 002000h Block Block CP1, WRT1, EBTR1 003FFFh 004000h Unimplemented Read 0’s Block Unimplemented Read 0’s Block CP2, WRT2, EBTR2 005FFFh 006000h CP3, WRT3, EBTR3 007FFFh 008000h Unimplemented Read 0’s Unimplemented Read 0’s (Unimplemented Memory Space) 1FFFFFh TABLE 19-3: SUMMARY OF CODE PROTECTION REGISTERS File Name Bit Bit Bit Bit Bit Bit Bit Bit 300008h CONFIG5L — — — — CP3 CP2 CP1 CP0 300009h CONFIG5H CPD CPB — — — — — — 30000Ah CONFIG6L — — — — WRT3 WRT2 WRT1 WRT0 30000Bh CONFIG6H WRTD WRTB WRTC — — — — — 30000Ch CONFIG7L — — — — EBTR3 EBTR2 EBTR1 EBTR0 30000Dh CONFIG7H — EBTRB — — — — — — Legend: Shaded cells are unimplemented © 2006 Microchip Technology Inc DS39564C-page 207 PIC18FXX2 19.4.1 PROGRAM MEMORY CODE PROTECTION The user memory may be read to or written from any location using the Table Read and Table Write instructions The device ID may be read with Table Reads The configuration registers may be read and written with the Table Read and Table Write instructions outside of that block is not allowed to read, and will result in reading ‘0’s Figures 19-4 through 19-6 illustrate Table Write and Table Read protection Note: In User mode, the CPn bits have no direct effect CPn bits inhibit external reads and writes A block of user memory may be protected from Table Writes if the WRTn configuration bit is ‘0’ The EBTRn bits control Table Reads For a block of user memory with the EBTRn bit set to ‘0’, a Table Read instruction that executes from within that block is allowed to read A Table Read instruction that executes from a location FIGURE 19-4: Code protection bits may only be written to a ‘0’ from a ‘1’ state It is not possible to write a ‘1’ to a bit in the ‘0’ state Code protection bits are only set to ‘1’ by a full chip erase or block erase function The full chip erase and block erase functions can only be initiated via ICSP or an external programmer TABLE WRITE (WRTn) DISALLOWED Register Values Program Memory Configuration Bit Settings 000000h 0001FFh 000200h WRTB,EBTRB = 11 TBLPTR = 000FFF WRT0,EBTR0 = 01 PC = 001FFE TBLWT * 001FFFh 002000h WRT1,EBTR1 = 11 003FFFh 004000h PC = 004FFE WRT2,EBTR2 = 11 TBLWT * 005FFFh 006000h WRT3,EBTR3 = 11 007FFFh Results: All Table Writes disabled to Blockn whenever WRTn = ‘0’ DS39564C-page 208 © 2006 Microchip Technology Inc PIC18FXX2 FIGURE 19-5: EXTERNAL BLOCK TABLE READ (EBTRn) DISALLOWED Register Values Program Memory Configuration Bit Settings 000000h WRTB,EBTRB = 11 0001FFh 000200h TBLPTR = 000FFF WRT0,EBTR0 = 10 001FFFh 002000h PC = 002FFE TBLRD * WRT1,EBTR1 = 11 003FFFh 004000h WRT2,EBTR2 = 11 005FFFh 006000h WRT3,EBTR3 = 11 007FFFh Results: All Table Reads from external blocks to Blockn are disabled whenever EBTRn = ‘0’ TABLAT register returns a value of “0” FIGURE 19-6: EXTERNAL BLOCK TABLE READ (EBTRn) ALLOWED Register Values Program Memory Configuration Bit Settings 000000h WRTB,EBTRB = 11 0001FFh 000200h TBLPTR = 000FFF PC = 001FFE WRT0,EBTR0 = 10 TBLRD * 001FFFh 002000h WRT1,EBTR1 = 11 003FFFh 004000h WRT2,EBTR2 = 11 005FFFh 006000h WRT3,EBTR3 = 11 007FFFh Results: Table Reads permitted within Blockn, even when EBTRBn = ‘0’ TABLAT register returns the value of the data at the location TBLPTR © 2006 Microchip Technology Inc DS39564C-page 209 PIC18FXX2 19.4.2 DATA EEPROM CODE PROTECTION The entire Data EEPROM is protected from external reads and writes by two bits: CPD and WRTD CPD inhibits external reads and writes of Data EEPROM WRTD inhibits external writes to Data EEPROM The CPU can continue to read and write Data EEPROM regardless of the protection bit settings 19.4.3 CONFIGURATION REGISTER PROTECTION The configuration registers can be write protected The WRTC bit controls protection of the configuration registers In User mode, the WRTC bit is readable only WRTC can only be written via ICSP or an external programmer 19.5 ID Locations Eight memory locations (200000h - 200007h) are designated as ID locations, where the user can store checksum or other code identification numbers These locations are accessible during normal execution through the TBLRD and TBLWT instructions, or during program/verify The ID locations can be read when the device is code protected The sequence for programming the ID locations is similar to programming the FLASH memory (see Section 5.5.1) 19.6 In-Circuit Serial Programming PIC18FXXX microcontrollers can be serially programmed while in the end application circuit This is simply done with two lines for clock and data, and three other lines for power, ground and the programming voltage This allows customers to manufacture boards with unprogrammed devices, and then program the microcontroller just before shipping the product This also allows the most recent firmware or a custom firmware to be programmed 19.7 In-Circuit Debugger When the DEBUG bit in configuration register CONFIG4L is programmed to a '0', the In-Circuit Debugger functionality is enabled This function allows simple debugging functions when used with MPLAB® IDE When the microcontroller has this feature enabled, some of the resources are not available for general use Table 19-4 shows which features are consumed by the background debugger TABLE 19-4: DEBUGGER RESOURCES I/O pins Stack RB6, RB7 To use the In-Circuit Debugger function of the microcontroller, the design must implement In-Circuit Serial Programming connections to MCLR/VPP, VDD, GND, RB7 and RB6 This will interface to the In-Circuit Debugger module available from Microchip or one of the third party development tool companies 19.8 Low Voltage ICSP Programming The LVP bit configuration register CONFIG4L enables low voltage ICSP programming This mode allows the microcontroller to be programmed via ICSP using a VDD source in the operating voltage range This only means that VPP does not have to be brought to VIHH, but can instead be left at the normal operating voltage In this mode, the RB5/PGM pin is dedicated to the programming function and ceases to be a general purpose I/O pin During programming, VDD is applied to the MCLR/VPP pin To enter Programming mode, VDD must be applied to the RB5/PGM, provided the LVP bit is set The LVP bit defaults to a (‘1’) from the factory Note 1: The High Voltage Programming mode is always available, regardless of the state of the LVP bit, by applying VIHH to the MCLR pin 2: While in low voltage ICSP mode, the RB5 pin can no longer be used as a general purpose I/O pin, and should be held low during normal operation to protect against inadvertent ICSP mode entry 3: When using low voltage ICSP programming (LVP), the pull-up on RB5 becomes disabled If TRISB bit is cleared, thereby setting RB5 as an output, LATB bit must also be cleared for proper operation If Low Voltage Programming mode is not used, the LVP bit can be programmed to a '0' and RB5/PGM becomes a digital I/O pin However, the LVP bit may only be programmed when programming is entered with VIHH on MCLR/VPP It should be noted that once the LVP bit is programmed to 0, only the High Voltage Programming mode is available and only High Voltage Programming mode can be used to program the device When using low voltage ICSP, the part must be supplied 4.5V to 5.5V, if a bulk erase will be executed This includes reprogramming of the code protect bits from an on-state to off-state For all other cases of low voltage ICSP, the part may be programmed at the normal operating voltage This means unique user IDs, or user code can be reprogrammed or added levels Program Memory 512 bytes Data Memory 10 bytes DS39564C-page 210 © 2006 Microchip Technology Inc PIC18FXX2 20.0 INSTRUCTION SET SUMMARY The PIC18FXXX instruction set adds many enhancements to the previous PICmicro instruction sets, while maintaining an easy migration from these PICmicro instruction sets Most instructions are a single program memory word (16-bits), but there are three instructions that require two program memory locations Each single word instruction is a 16-bit word divided into an OPCODE, which specifies the instruction type and one or more operands, which further specify the operation of the instruction The instruction set is highly orthogonal and is grouped into four basic categories: • • • • Byte-oriented operations Bit-oriented operations Literal operations Control operations The PIC18FXXX instruction set summary in Table 20-2 lists byte-oriented, bit-oriented, literal and control operations Table 20-1 shows the opcode field descriptions Most byte-oriented instructions have three operands: The file register (specified by ‘f’) The destination of the result (specified by ‘d’) The accessed memory (specified by ‘a’) The file register designator 'f' specifies which file register is to be used by the instruction The destination designator ‘d’ specifies where the result of the operation is to be placed If 'd' is zero, the result is placed in the WREG register If 'd' is one, the result is placed in the file register specified in the instruction The literal instructions may use some of the following operands: • A literal value to be loaded into a file register (specified by ‘k’) • The desired FSR register to load the literal value into (specified by ‘f’) • No operand required (specified by ‘—’) The control instructions may use some of the following operands: • A program memory address (specified by ‘n’) • The mode of the Call or Return instructions (specified by ‘s’) • The mode of the Table Read and Table Write instructions (specified by ‘m’) • No operand required (specified by ‘—’) All instructions are a single word, except for three double-word instructions These three instructions were made double-word instructions so that all the required information is available in these 32 bits In the second word, the 4-MSbs are 1’s If this second word is executed as an instruction (by itself), it will execute as a NOP All single word instructions are executed in a single instruction cycle, unless a conditional test is true or the program counter is changed as a result of the instruction In these cases, the execution takes two instruction cycles with the additional instruction cycle(s) executed as a NOP The double-word instructions execute in two instruction cycles All bit-oriented instructions have three operands: One instruction cycle consists of four oscillator periods Thus, for an oscillator frequency of MHz, the normal instruction execution time is μs If a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is μs Two-word branch instructions (if true) would take μs Figure 20-1 shows the general formats that the instructions can have The file register (specified by ‘f’) The bit in the file register (specified by ‘b’) The accessed memory (specified by ‘a’) The bit field designator 'b' selects the number of the bit affected by the operation, while the file register designator 'f' represents the number of the file in which the bit is located © 2006 Microchip Technology Inc All examples use the format ‘nnh’ to represent a hexadecimal number, where ‘h’ signifies a hexadecimal digit The Instruction Set Summary, shown in Table 20-2, lists the instructions recognized by the Microchip Assembler (MPASMTM) Section 20.1 provides a description of each instruction DS39564C-page 211 PIC18FXX2 TABLE 20-1: OPCODE FIELD DESCRIPTIONS Field Description a RAM access bit a = 0: RAM location in Access RAM (BSR register is ignored) a = 1: RAM bank is specified by BSR register bbb Bit address within an 8-bit file register (0 to 7) BSR Bank Select Register Used to select the current RAM bank d Destination select bit; d = 0: store result in WREG, d = 1: store result in file register f dest Destination either the WREG register or the specified register file location f 8-bit Register file address (0x00 to 0xFF) fs 12-bit Register file address (0x000 to 0xFFF) This is the source address fd 12-bit Register file address (0x000 to 0xFFF) This is the destination address k Literal field, constant data or label (may be either an 8-bit, 12-bit or a 20-bit value) label Label name mm The mode of the TBLPTR register for the Table Read and Table Write instructions Only used with Table Read and Table Write instructions: * No Change to register (such as TBLPTR with Table reads and writes) *+ Post-Increment register (such as TBLPTR with Table reads and writes) *- Post-Decrement register (such as TBLPTR with Table reads and writes) +* Pre-Increment register (such as TBLPTR with Table reads and writes) n The relative address (2’s complement number) for relative branch instructions, or the direct address for Call/Branch and Return instructions PRODH Product of Multiply high byte PRODL Product of Multiply low byte s Fast Call/Return mode select bit s = 0: not update into/from shadow registers s = 1: certain registers loaded into/from shadow registers (Fast mode) u Unused or Unchanged WREG Working register (accumulator) x Don't care (0 or 1) The assembler will generate code with x = It is the recommended form of use for compatibility with all Microchip software tools TBLPTR 21-bit Table Pointer (points to a Program Memory location) TABLAT 8-bit Table Latch TOS Top-of-Stack PC Program Counter PCL Program Counter Low Byte PCH Program Counter High Byte PCLATH Program Counter High Byte Latch PCLATU Program Counter Upper Byte Latch GIE Global Interrupt Enable bit WDT Watchdog Timer TO Time-out bit PD Power-down bit C, DC, Z, OV, N ALU status bits Carry, Digit Carry, Zero, Overflow, Negative [ ] Optional ( ) Contents → Assigned to < > Register bit field ∈ In the set of italics User defined term (font is courier) DS39564C-page 212 © 2006 Microchip Technology Inc PIC18FXX2 FIGURE 20-1: GENERAL FORMAT FOR INSTRUCTIONS Byte-oriented file register operations 15 10 OPCODE d a Example Instruction ADDWF MYREG, W, B f (FILE #) d = for result destination to be WREG register d = for result destination to be file register (f) a = to force Access Bank a = for BSR to select bank f = 8-bit file register address Byte to Byte move operations (2-word) 15 12 11 OPCODE 15 f (Source FILE #) 12 11 MOVFF MYREG1, MYREG2 f (Destination FILE #) 1111 f = 12-bit file register address Bit-oriented file register operations 15 12 11 OPCODE b (BIT #) a BSF MYREG, bit, B f (FILE #) b = 3-bit position of bit in file register (f) a = to force Access Bank a = for BSR to select bank f = 8-bit file register address Literal operations 15 OPCODE MOVLW 0x7F k (literal) k = 8-bit immediate value Control operations CALL, GOTO and Branch operations 15 OPCODE 15 GOTO Label n (literal) 12 11 n (literal) 1111 n = 20-bit immediate value 15 OPCODE 15 S CALL MYFUNC n (literal) 12 11 n (literal) S = Fast bit 15 OPCODE 15 OPCODE © 2006 Microchip Technology Inc 11 10 BRA MYFUNC n (literal) n (literal) BC MYFUNC DS39564C-page 213 PIC18FXX2 BNOV Branch if Not Overflow BNZ Branch if Not Zero Syntax: [ label ] BNOV Syntax: [ label ] BNZ Operands: -128 ≤ n ≤ 127 Operands: -128 ≤ n ≤ 127 Operation: if overflow bit is ’0’ (PC) + + 2n → PC Operation: if zero bit is ’0’ (PC) + + 2n → PC Status Affected: None Status Affected: None Encoding: 1110 n 0101 nnnn nnnn Encoding: 1110 n 0001 nnnn nnnn Description: If the Overflow bit is ’0’, then the program will branch The 2’s complement number ’2n’ is added to the PC Since the PC will have incremented to fetch the next instruction, the new address will be PC+2+2n This instruction is then a two-cycle instruction Description: If the Zero bit is ’0’, then the program will branch The 2’s complement number ’2n’ is added to the PC Since the PC will have incremented to fetch the next instruction, the new address will be PC+2+2n This instruction is then a two-cycle instruction Words: Words: Cycles: 1(2) Cycles: 1(2) Q Cycle Activity: If Jump: Q1 Q Cycle Activity: If Jump: Q1 Q2 Q3 Q4 Q2 Q3 Q4 Decode Read literal 'n' Process Data Write to PC Decode Read literal 'n' Process Data Write to PC No operation No operation No operation No operation No operation No operation No operation No operation Q2 Q3 Q4 Read literal 'n' Process Data No operation If No Jump: Q1 Decode Example: HERE BNOV Jump Before Instruction PC DS39564C-page 222 Decode Example: Q2 Q3 Q4 Read literal 'n' Process Data No operation HERE BNZ Jump Before Instruction = address (HERE) After Instruction If Overflow PC If Overflow PC If No Jump: Q1 PC = address (HERE) = = = = 0; address (Jump) 1; address (HERE+2) After Instruction = = = = 0; address (Jump) 1; address (HERE+2) If Zero PC If Zero PC © 2006 Microchip Technology Inc PIC18FXX2 BRA Unconditional Branch BSF Bit Set f Syntax: [ label ] BRA Syntax: [ label ] BSF Operands: -1024 ≤ n ≤ 1023 Operands: Operation: (PC) + + 2n → PC Status Affected: None ≤ f ≤ 255 0≤b≤7 a ∈ [0,1] Operation: → f Status Affected: None Encoding: Description: 1101 n 0nnn nnnn nnnn Add the 2’s complement number ’2n’ to the PC Since the PC will have incremented to fetch the next instruction, the new address will be PC+2+2n This instruction is a two-cycle instruction Encoding: Cycles: Q Cycle Activity: Q1 Bit 'b' in register 'f' is set If ‘a’ is Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value 1 Q2 Q3 Q4 Read literal 'n' Process Data Write to PC No operation No operation Q Cycle Activity: Q1 No operation Decode Example: HERE BRA Jump PC Q2 Q3 Q4 Read register 'f' Process Data Write register 'f' BSF = address (HERE) = FLAG_REG, 7, Before Instruction FLAG_REG Before Instruction = 0x0A = 0x8A After Instruction address (Jump) After Instruction PC ffff Words: Example: ffff Description: No operation bbba Cycles: Words: Decode 1000 f,b[,a] © 2006 Microchip Technology Inc FLAG_REG DS39564C-page 223 PIC18FXX2 BTFSC Bit Test File, Skip if Clear BTFSS Bit Test File, Skip if Set Syntax: [ label ] BTFSC f,b[,a] Syntax: [ label ] BTFSS f,b[,a] Operands: ≤ f ≤ 255 0≤b≤7 a ∈ [0,1] Operands: ≤ f ≤ 255 0≤b≤7 a ∈ [0,1] Operation: skip if (f) = Operation: skip if (f) = Status Affected: None Status Affected: None Encoding: 1011 bbba ffff ffff Encoding: 1010 bbba ffff ffff Description: If bit 'b' in register ’f' is 0, then the next instruction is skipped If bit 'b' is 0, then the next instruction fetched during the current instruction execution is discarded, and a NOP is executed instead, making this a twocycle instruction If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Description: If bit 'b' in register 'f' is 1, then the next instruction is skipped If bit 'b' is 1, then the next instruction fetched during the current instruction execution, is discarded and a NOP is executed instead, making this a two-cycle instruction If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Words: Words: Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Cycles: 1(2) Note: Q Cycle Activity: Q1 Q Cycle Activity: Q1 cycles if skip and followed by a 2-word instruction Q2 Q3 Q4 Decode Read register 'f' Process Data No operation Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation If skip: Q2 Q3 Q4 Read register 'f' Decode Process Data No operation If skip: If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation Example: HERE FALSE TRUE BTFSC : : FLAG, 1, Before Instruction PC DS39564C-page 224 HERE FALSE TRUE BTFSS : : FLAG, 1, Before Instruction = address (HERE) After Instruction If FLAG PC If FLAG PC Example: PC = address (HERE) = = = = 0; address (FALSE) 1; address (TRUE) After Instruction = = = = 0; address (TRUE) 1; address (FALSE) If FLAG PC If FLAG PC © 2006 Microchip Technology Inc PIC18FXX2 BTG Bit Toggle f BOV Branch if Overflow Syntax: [ label ] BTG f,b[,a] Syntax: [ label ] BOV Operands: ≤ f ≤ 255 0≤b≤7 a ∈ [0,1] Operands: -128 ≤ n ≤ 127 Operation: if overflow bit is ’1’ (PC) + + 2n → PC Status Affected: None Operation: (f) → f Status Affected: None Encoding: Encoding: 0111 bbba ffff ffff 1110 0100 nnnn nnnn Description: If the Overflow bit is ’1’, then the program will branch The 2’s complement number ’2n’ is added to the PC Since the PC will have incremented to fetch the next instruction, the new address will be PC+2+2n This instruction is then a two-cycle instruction Words: Cycles: Description: 1(2) Bit 'b' in data memory location 'f' is inverted If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Words: Cycles: Q Cycle Activity: Q1 Decode n Q2 Q3 Q4 Read register 'f' Process Data Write register 'f' Q Cycle Activity: If Jump: Q1 Example: BTG PORTC, = 0111 0101 [0x75] After Instruction: PORTC = Q3 Q4 Read literal 'n' Process Data Write to PC No operation No operation No operation No operation 4, Before Instruction: PORTC Q2 Decode 0110 0101 [0x65] If No Jump: Q1 Decode Q2 Q3 Q4 Read literal 'n' Process Data No operation Example: HERE BOV Jump Before Instruction PC = address (HERE) = = = = 1; address (Jump) 0; address (HERE+2) After Instruction If Overflow PC If Overflow PC © 2006 Microchip Technology Inc DS39564C-page 225 PIC18FXX2 BZ Branch if Zero CALL Subroutine Call Syntax: [ label ] BZ Syntax: [ label ] CALL k [,s] Operands: -128 ≤ n ≤ 127 Operands: Operation: if Zero bit is ’1’ (PC) + + 2n → PC ≤ k ≤ 1048575 s ∈ [0,1] Operation: (PC) + → TOS, k → PC, if s = (W) → WS, (STATUS) → STATUSS, (BSR) → BSRS Status Affected: None Status Affected: n None Encoding: 1110 Description: 0000 nnnn nnnn If the Zero bit is ’1’, then the program will branch The 2’s complement number ’2n’ is added to the PC Since the PC will have incremented to fetch the next instruction, the new address will be PC+2+2n This instruction is then a two-cycle instruction Encoding: 1st word (k) 2nd word(k) 110s k19kkk k7kkk kkkk kkkk0 kkkk8 Subroutine call of entire Mbyte memory range First, return address (PC+ 4) is pushed onto the return stack If ’s’ = 1, the W, STATUS and BSR registers are also pushed into their respective shadow registers, WS, STATUSS and BSRS If 's' = 0, no update occurs (default) Then, the 20-bit value ’k’ is loaded into PC CALL is a two-cycle instruction Cycles: Cycles: Description: Words: Words: 1(2) Q Cycle Activity: If Jump: Q1 Q2 Q3 Q4 Decode Read literal 'n' Process Data Write to PC No operation No operation No operation No operation If No Jump: Q1 Decode 1110 1111 Q2 Q3 Q4 Read literal 'n' Process Data No operation Q Cycle Activity: Q1 Example: HERE BZ Q2 Q3 Q4 Decode Read literal 'k', Push PC to stack Read literal ’k’, Write to PC No operation No operation No operation No operation Jump Before Instruction PC = address (HERE) = = = = 1; address (Jump) 0; address (HERE+2) After Instruction If Zero PC If Zero PC Example: HERE CALL THERE,1 Before Instruction PC = address (HERE) After Instruction PC = TOS = WS = BSRS = STATUSS= DS39564C-page 226 address (THERE) address (HERE + 4) W BSR STATUS © 2006 Microchip Technology Inc PIC18FXX2 CLRF Clear f CLRWDT Syntax: [ label ] CLRF Operands: ≤ f ≤ 255 a ∈ [0,1] Operation: [ label ] CLRWDT Operands: None Operation: 000h → WDT, 000h → WDT postscaler, → TO, → PD Status Affected: TO, PD 000h → f 1→Z Status Affected: Syntax: f [,a] Clear Watchdog Timer Z Encoding: Description: 0110 101a ffff ffff Encoding: 0000 0000 0000 0100 Clears the contents of the specified register If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Description: CLRWDT instruction resets the Watchdog Timer It also resets the postscaler of the WDT Status bits TO and PD are set Words: Words: Cycles: Cycles: Q Cycle Activity: Q1 Decode Q Cycle Activity: Q1 Q2 Q3 Q4 Read register 'f' Process Data Write register 'f' Decode Example: Example: CLRF FLAG_REG,1 Before Instruction FLAG_REG Q3 Q4 Process Data No operation CLRWDT Before Instruction WDT Counter = 0x5A = 0x00 After Instruction FLAG_REG Q2 No operation © 2006 Microchip Technology Inc = ? = = = = 0x00 1 After Instruction WDT Counter WDT Postscaler TO PD DS39564C-page 227 PIC18FXX2 COMF Complement f Syntax: [ label ] COMF Operands: ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operation: ( f ) → dest Status Affected: N, Z Encoding: 0001 Description: Syntax: ffff ffff The contents of register 'f' are complemented If 'd' is 0, the result is stored in W If 'd' is 1, the result is stored back in register 'f' (default) If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Words: ≤ f ≤ 255 a ∈ [0,1] (f) – (W), skip if (f) = (W) (unsigned comparison) Status Affected: None Encoding: Decode ffff Q2 Q3 Q4 Words: Process Data Write to destination Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction COMF Before Instruction = 0x13 After Instruction REG W ffff Read register 'f' Example: REG 001a Compares the contents of data memory location 'f' to the contents of W by performing an unsigned subtraction If 'f' = W, then the fetched instruction is discarded and a NOP is executed instead, making this a twocycle instruction If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Q Cycle Activity: Q1 0110 f [,a] Description: Cycles: [ label ] CPFSEQ Operation: f [,d [,a] Compare f with W, skip if f = W Operands: 11da CPFSEQ = = 0x13 0xEC REG, 0, Q Cycle Activity: Q1 Decode Q2 Q3 Q4 Read register 'f' Process Data No operation If skip: Q1 Q2 Q3 Q4 No operation No operation No operation No operation If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation Example: HERE NEQUAL EQUAL CPFSEQ REG, : : Before Instruction PC Address W REG = = = HERE ? ? = = ≠ = W; Address (EQUAL) W; Address (NEQUAL) After Instruction If REG PC If REG PC DS39564C-page 228 © 2006 Microchip Technology Inc PIC18FXX2 CPFSGT Compare f with W, skip if f > W CPFSLT Compare f with W, skip if f < W Syntax: [ label ] CPFSGT Syntax: [ label ] CPFSLT Operands: ≤ f ≤ 255 a ∈ [0,1] Operands: ≤ f ≤ 255 a ∈ [0,1] Operation: (f) − (W), skip if (f) > (W) (unsigned comparison) Operation: (f) – (W), skip if (f) < (W) (unsigned comparison) Status Affected: None Status Affected: None Encoding: Description: 0110 010a f [,a] ffff ffff Compares the contents of data memory location 'f' to the contents of the W by performing an unsigned subtraction If the contents of 'f' are greater than the contents of WREG, then the fetched instruction is discarded and a NOP is executed instead, making this a two-cycle instruction If ‘a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Words: Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Q Cycle Activity: Q1 Decode Encoding: Q2 Q3 No operation If skip: Q1 Q2 Q3 Q4 No operation No operation No operation No operation If skip and followed by 2-word instruction: Q1 Q2 Q3 Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Q Cycle Activity: Q1 Q2 Q3 Q4 No operation No operation No operation If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation HERE NGREATER GREATER CPFSGT REG, : : Address (HERE) ? > = ≤ = W; Address (GREATER) W; Address (NGREATER) After Instruction If REG PC If REG PC © 2006 Microchip Technology Inc Q4 No operation Q1 No operation = = Q3 Process Data No operation No operation PC W Q2 Read register 'f' If skip: No operation Before Instruction ffff Words: No operation Example: ffff Compares the contents of data memory location 'f' to the contents of W by performing an unsigned subtraction If the contents of 'f' are less than the contents of W, then the fetched instruction is discarded and a NOP is executed instead, making this a two-cycle instruction If ‘a’ is 0, the Access Bank will be selected If ’a’ is 1, the BSR will not be overridden (default) Q4 Process Data 000a Description: Decode Read register 'f' 0110 f [,a] Example: Q4 No operation No operation No operation No operation No operation No operation HERE NLESS LESS CPFSLT REG, : : Before Instruction PC W = = Address (HERE) ? < = ≥ = W; Address (LESS) W; Address (NLESS) After Instruction If REG PC If REG PC DS39564C-page 229 PIC18FXX2 DAW Decimal Adjust W Register DECF Decrement f Syntax: [ label ] DAW Syntax: [ label ] DECF f [,d [,a] Operands: None Operands: Operation: If [W >9] or [DC = 1] then (W) + → W; else (W) → W; ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operation: (f) – → dest Status Affected: C, DC, N, OV, Z If [W >9] or [C = 1] then (W) + → W; else (W) → W; Status Affected: Encoding: 0000 0000 0000 Cycles: Q Cycle Activity: Q1 Q2 Q3 Cycles: Write W Q2 Q3 Q4 Read register 'f' Process Data Write to destination Q4 Process Data ffff Words: Decode Read register W ffff Decrement register 'f' If 'd' is 0, the result is stored in W If 'd' is 1, the result is stored back in register 'f' (default) If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Q Cycle Activity: Q1 01da Description: 0111 DAW adjusts the eight-bit value in W, resulting from the earlier addition of two variables (each in packed BCD format) and produces a correct packed BCD result Words: Example1: DAW Before Instruction W C DC 0000 C Description: Decode Encoding: = = = 0xA5 0 Example: DECF CNT, 1, Before Instruction CNT Z = = 0x01 After Instruction CNT Z = = 0x00 After Instruction W C DC = = = 0x05 Example 2: Before Instruction W C DC = = = 0xCE 0 After Instruction W C DC = = = DS39564C-page 230 0x34 © 2006 Microchip Technology Inc PIC18FXX2 DECFSZ Decrement f, skip if DCFSNZ Decrement f, skip if not Syntax: [ label ] DECFSZ f [,d [,a]] Syntax: [ label ] DCFSNZ Operands: ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operands: ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operation: (f) – → dest, skip if result = Operation: (f) – → dest, skip if result ≠ Status Affected: None Status Affected: None Encoding: 0010 11da ffff ffff Encoding: 0100 11da f [,d [,a] ffff ffff Description: The contents of register 'f' are decremented If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) If the result is 0, the next instruction, which is already fetched, is discarded, and a NOP is executed instead, making it a two-cycle instruction If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Description: The contents of register 'f' are decremented If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) If the result is not 0, the next instruction, which is already fetched, is discarded, and a NOP is executed instead, making it a twocycle instruction If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Words: Words: Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Q Cycle Activity: Q1 Q Cycle Activity: Q1 Q2 Q3 Q4 Read register 'f' Process Data Write to destination Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation Decode If skip: Decode Q2 Q3 Q4 Read register 'f' Process Data Write to destination If skip: If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation DECFSZ GOTO CNT, 1, LOOP Example: HERE Example: CONTINUE Before Instruction PC = = = = ≠ = DCFSNZ : : TEMP, 1, Before Instruction Address (HERE) After Instruction CNT If CNT PC If CNT PC HERE ZERO NZERO TEMP = ? = = = ≠ = TEMP - 1, 0; Address (ZERO) 0; Address (NZERO) After Instruction CNT - 0; Address (CONTINUE) 0; Address (HERE+2) © 2006 Microchip Technology Inc TEMP If TEMP PC If TEMP PC DS39564C-page 231 PIC18FXX2 GOTO Unconditional Branch INCF Increment f Syntax: [ label ] Syntax: [ label ] Operands: ≤ k ≤ 1048575 Operands: Operation: k → PC Status Affected: None ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operation: (f) + → dest Status Affected: C, DC, N, OV, Z Encoding: 1st word (k) 2nd word(k) Description: 1110 1111 GOTO k 1111 k19kkk k7kkk kkkk kkkk0 kkkk8 GOTO allows an unconditional branch anywhere within entire Mbyte memory range The 20-bit value ’k’ is loaded into PC GOTO is always a two-cycle instruction Encoding: 0010 f [,d [,a] 10da ffff ffff The contents of register 'f' are incremented If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Cycles: Cycles: Description: Words: Words: Q Cycle Activity: Q1 Q2 Q3 Q4 Decode Read literal 'k', No operation Read literal ’k’, Write to PC No operation No operation No operation No operation Example: GOTO THERE After Instruction PC = INCF Address (THERE) Q Cycle Activity: Q1 Decode Q2 Q3 Q4 Read register 'f' Process Data Write to destination Example: INCF CNT, 1, Before Instruction CNT Z C DC = = = = 0xFF ? ? After Instruction CNT Z C DC DS39564C-page 232 = = = = 0x00 1 © 2006 Microchip Technology Inc PIC18FXX2 INCFSZ Increment f, skip if INFSNZ Increment f, skip if not Syntax: [ label ] Syntax: [ label ] Operands: ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operands: ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operation: (f) + → dest, skip if result = Operation: (f) + → dest, skip if result ≠ Status Affected: None Status Affected: None Encoding: 0011 INCFSZ 11da f [,d [,a] ffff ffff Encoding: 0100 INFSNZ 10da f [,d [,a] ffff ffff Description: The contents of register 'f' are incremented If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) If the result is 0, the next instruction, which is already fetched, is discarded, and a NOP is executed instead, making it a two-cycle instruction If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Description: The contents of register 'f' are incremented If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) If the result is not 0, the next instruction, which is already fetched, is discarded, and a NOP is executed instead, making it a twocycle instruction If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Words: Words: Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Cycles: 1(2) Note: cycles if skip and followed by a 2-word instruction Q Cycle Activity: Q1 Q Cycle Activity: Q1 Q2 Q3 Q4 Read register 'f' Process Data Write to destination Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation Decode If skip: Decode Q2 Q3 Q4 Read register 'f' Process Data Write to destination If skip: If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction: Q1 Q2 Q3 Q4 No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation No operation Example: HERE NZERO ZERO INCFSZ : : Before Instruction PC = = = = ≠ = Example: HERE ZERO NZERO INFSNZ REG, 1, Before Instruction Address (HERE) After Instruction CNT If CNT PC If CNT PC CNT, 1, PC = Address (HERE) After Instruction CNT + 0; Address (ZERO) 0; Address (NZERO) © 2006 Microchip Technology Inc REG If REG PC If REG PC = ≠ = = = REG + 0; Address (NZERO) 0; Address (ZERO) DS39564C-page 233 PIC18FXX2 IORLW Inclusive OR literal with W IORWF Inclusive OR W with f Syntax: [ label ] Syntax: [ label ] Operands: ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Operation: (W) OR (f) → dest Status Affected: N, Z IORLW k Operands: ≤ k ≤ 255 Operation: (W) OR k → W Status Affected: N, Z Encoding: 0000 Description: 1001 kkkk kkkk The contents of W are OR’ed with the eight-bit literal 'k' The result is placed in W Encoding: 0001 IORWF 00da f [,d [,a] ffff ffff Cycles: 1 Cycles: Inclusive OR W with register 'f' If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ’a’ = 1, then the bank will be selected as per the BSR value (default) Words: Words: Description: Q Cycle Activity: Q1 Q2 Example: Q3 Q4 Read literal 'k' Decode Process Data Write to W IORLW Before Instruction W = 0x9A After Instruction W = 0x35 Q Cycle Activity: Q1 Decode 0xBF Q2 Q3 Q4 Read register 'f' Process Data Write to destination IORWF RESULT, 0, Example: Before Instruction RESULT = W = 0x13 0x91 After Instruction RESULT = W = DS39564C-page 234 0x13 0x93 © 2006 Microchip Technology Inc PIC18FXX2 LFSR Load FSR MOVF Move f Syntax: [ label ] Syntax: [ label ] Operands: 0≤f≤2 ≤ k ≤ 4095 Operands: Operation: k → FSRf ≤ f ≤ 255 d ∈ [0,1] a ∈ [0,1] Status Affected: None Operation: f → dest Status Affected: N, Z Encoding: LFSR f,k 1110 1111 1110 0000 00ff k7kkk k11kkk kkkk Description: The 12-bit literal 'k' is loaded into the file select register pointed to by 'f' Words: Cycles: Encoding: MOVF 0101 f [,d [,a] 00da ffff ffff Q2 Q3 Read literal 'k' MSB Process Data Read literal 'k' LSB Process Data Write literal 'k' to FSRfL 1 Write literal 'k' MSB to FSRfH Decode Words: Q4 Decode The contents of register 'f' are moved to a destination dependent upon the status of ’d’ If 'd' is 0, the result is placed in W If 'd' is 1, the result is placed back in register 'f' (default) Location 'f' can be anywhere in the 256 byte bank If ’a’ is 0, the Access Bank will be selected, overriding the BSR value If ‘a’ = 1, then the bank will be selected as per the BSR value (default) Cycles: Q Cycle Activity: Q1 Description: Example: LFSR 2, 0x3AB After Instruction FSR2H FSR2L = = 0x03 0xAB Q Cycle Activity: Q1 Decode Example: Q2 Q3 Q4 Read register 'f' Process Data Write W MOVF REG, 0, Before Instruction REG W = = 0x22 0xFF = = 0x22 0x22 After Instruction REG W © 2006 Microchip Technology Inc DS39564C-page 235 PIC18FXX2 MOVFF Move f to f MOVLB Move literal to low nibble in BSR Syntax: [ label ] Syntax: [ label ] Operands: ≤ fs ≤ 4095 ≤ fd ≤ 4095 Operands: ≤ k ≤ 255 Operation: k → BSR None MOVFF fs,fd Operation: (fs) → fd Status Affected: Status Affected: None Encoding: Encoding: 1st word (source) 2nd word (destin.) 1100 1111 Description: ffff ffff ffff ffff ffffs ffffd The contents of source register 'fs' are moved to destination register 'fd' Location of source 'fs' can be anywhere in the 4096 byte data space (000h to FFFh), and location of destination 'fd' can also be anywhere from 000h to FFFh Either source or destination can be W (a useful special situation) MOVFF is particularly useful for transferring a data memory location to a peripheral register (such as the transmit buffer or an I/O port) The MOVFF instruction cannot use the PCL, TOSU, TOSH or TOSL as the destination register Note: Words: 0000 0001 kkkk kkkk Description: The 8-bit literal 'k' is loaded into the Bank Select Register (BSR) Words: Cycles: Q Cycle Activity: Q1 Decode Example: Q2 Q3 Q4 Read literal 'k' Process Data Write literal 'k' to BSR MOVLB Before Instruction BSR register = 0x02 = 0x05 After Instruction BSR register The MOVFF instruction should not be used to modify interrupt settings while any interrupt is enabled See Section 8.0 for more information Cycles: MOVLB k (3) Q Cycle Activity: Q1 Q2 Q3 Q4 Decode Read register 'f' (src) Process Data No operation Decode No operation No operation Write register 'f' (dest) No dummy read Example: MOVFF REG1, REG2 Before Instruction REG1 REG2 = = 0x33 0x11 = = 0x33, 0x33 After Instruction REG1 REG2 DS39564C-page 236 © 2006 Microchip Technology Inc ... Operation: (f) – → dest Status Affected: C, DC, N, OV, Z If [W >9] or [C = 1] then (W ) + → W ; else (W ) → W ; Status Affected: Encoding: 0000 0000 0000 Cycles: Q Cycle... Process Data Write register ''f'' Q Cycle Activity: If Jump: Q1 Example: BCF Before Instruction FLAG_REG = 0xC7 After Instruction FLAG_REG = 0x 47 FLAG_REG, Q2 Q3 Q4 Decode Read literal ''n'' Process Data. .. Q4 Read register ''f'' Process Data Write to destination Example: ANDWF REG, 0, Before Instruction W REG = = 0x 17 0xC2 = = Q2 Q3 Q4 Decode Read literal ''n'' Process Data Write to PC No operation

Ngày đăng: 07/08/2014, 23:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan