12.07.2015 Views

PIC16F84A 18-pin Enhanced Flash/EEPROM 8-Bit MCU Data Sheet

PIC16F84A 18-pin Enhanced Flash/EEPROM 8-Bit MCU Data Sheet

PIC16F84A 18-pin Enhanced Flash/EEPROM 8-Bit MCU Data Sheet

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PIC16F84A</strong>2.3 PCL and PCLATHThe program counter (PC) specifies the address of theinstruction to fetch for execution. The PC is 13 bitswide. The low byte is called the PCL register. This registeris readable and writable. The high byte is calledthe PCH register. This register contains the PCbits and is not directly readable or writable. All updatesto the PCH register go through the PCLATH register.2.3.1 STACKThe stack allows a combination of up to 8 program callsand interrupts to occur. The stack contains the returnaddress from this branch in program execution.Midrange devices have an 8 level deep x 13-bit widehardware stack. The stack space is not part of eitherprogram or data space and the stack pointer is notreadable or writable. The PC is PUSHed onto the stackwhen a CALL instruction is executed or an interruptcauses a branch. The stack is POPed in the event of aRETURN, RETLW or a RETFIE instruction execution.PCLATH is not modified when the stack is PUSHed orPOPed.After the stack has been PUSHed eight times, the ninthpush overwrites the value that was stored from the firstpush. The tenth push overwrites the second push (andso on).2.4 Indirect Addressing; INDF and FSRRegistersThe INDF register is not a physical register. AddressingINDF actually addresses the register whoseaddress is contained in the FSR register (FSR is apointer). This is indirect addressing.EXAMPLE 2-1: INDIRECT ADDRESSING• Register file 05 contains the value 10h• Register file 06 contains the value 0Ah• Load the value 05 into the FSR register• A read of the INDF register will return the value of10h• Increment the value of the FSR register by one(FSR = 06)• A read of the INDF register now will return thevalue of 0Ah.Reading INDF itself indirectly (FSR = 0) will produce00h. Writing to the INDF register indirectly results in ano-operation (although STATUS bits may be affected).A simple program to clear RAM locations 20h-2Fhusing indirect addressing is shown in Example 2-2.EXAMPLE 2-2: HOW TO CLEAR RAMUSING INDIRECTADDRESSINGmovlw 0x20 ;initialize pointermovwf FSR ; to RAMNEXT clrf INDF ;clear INDF registerincf FSR ;inc pointerbtfss FSR,4 ;all done?goto NEXT ;NO, clear nextCONTINUE: ;YES, continueAn effective 9-bit address is obtained by concatenatingthe 8-bit FSR register and the IRP bit (STATUS), asshown in Figure 2-1. However, IRP is not used in the<strong>PIC16F84A</strong>.© 1998 Microchip Technology Inc. Preliminary DS35007A-page 11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!