WritingToFSR

Discussion in 'Programmer's Corner' started by mpuvdd, Mar 25, 2008.

  1. mpuvdd

    Thread Starter Active Member

    Feb 11, 2007
    50
    0
    Hello everyone,
    I read that to quickly change the values of TRISA in a PIC16F684, you can load the FSR with the desired value, then simply write to the register pointed to by the FSR. What exactly is the FSR and how does doing this result in a faster write to TRISA? I've read some about this but don't fully understand it.
    Thanks a lot,
    mpuvdd
     
  2. Young_SR

    New Member

    Jan 9, 2008
    5
    0
    Hi mpuvdd,

    The op-code for a MOVWF assembler instruction (for example) can only hold a 7-bit address value (00h to 7Fh).

    For the 16F684, data file registers (data memory) are implemented in two address segments- address 00h to 7Fh (Bank0) and at 80h to FFh (bank1) where the TRISA register resides.

    This memory region 80h to FFh is unreachable with the 7-bit addressing limitation, as used by the opcode.

    A workaround to this limitation is to provide 1 or 2 functioning bit locations in the STATUS register (RP0,RP1) to provide a manual means, by the programmer (you), to extend the addressing range in combination with the op-code address. RP0 becomes the 8th bit of the memory address, and RP1 becomes the ninth bit (although it is not implemented in this chip). When the instruction is executed with a user memory 7-bit address, the ADDRESS Mux is loaded with the op-code address, plus the RP0 and RP1 bits from the STATUS register.

    The File Select Register (FSR) is a holding place for an 8-bit user memory address. In order to use the FSR you must use as your source/destination register, the INDF register. When the instruction is executed, using the INDF address (as in the instruction MOVWF INDF), the controller knows to load the 8-bit address stored in the FSR to the ADDRESS Mux and performs the data move without having to use RP0 and RP1. Note: the IRP bit in the STATUS register supplies the ninth bit but it is not implemented in this chip.

    Ok - that should take care of describing what the FSR is in 1000 words or less.

    What is a little harder to answer, is your question about fast changes to TRISA using the FSR register.

    Are you planning to make frequent changes to the TRIS register and collect and transmit data to PORTA?

    Steve
     
  3. mpuvdd

    Thread Starter Active Member

    Feb 11, 2007
    50
    0
    Great!
    That makes sense.
    Thanks so much Young_SR,
    mpuvdd
    P.S. And no, I was'nt planning on making frequent changes, it was just a one time deal.