LockedIndirect addressing ???

Author
Guest
Super Member
  • Total Posts : 80499
  • Reward points : 0
  • Joined: 2003/01/01 00:00:00
  • Location: 0
  • Status: online
2006/01/13 22:57:07 (permalink)
0

Indirect addressing ???

HI,
 
How to write and read data from memory using indirect addressing method?? Any coding examples??
 
Thanks a lot.
 
#1

7 Replies Related Threads

    Polyene
    Super Member
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2006/01/08 03:53:41
    • Location: Sweden
    • Status: offline
    RE: Indirect addressing ??? 2006/01/14 01:13:24 (permalink)
    0
    That depends a bit on which PIC you're using. Generally, you write the address of the variable that you wish to access into the FSR-register and then access it through the INDF-register.
    PIC18-processors has more advanced methods for indirect access than PIC16-processors. For example, PIC18 contains three FSR-registers, has special instructions for loading them, and in addition to INDF-registers, it also has POSTINC-registers and so on. It's all in the datasheet for your processor..
    #2
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Indirect addressing ??? 2006/01/14 06:59:09 (permalink)
    0
    I am using PIC18F.
     
    Let say I want to move 0x42, 0x43 and 0x44 to memory start from address 0x100. The coding is as below, am I right?


    movlw  0x01
    movwf  FSR0H
     
    movlw   0x42
    movwf   POSTINC0
    movlw   0x43
    movwf   POSTINC0 
    movlw   0x44
    movwf   POSTINC0   

    #3
    Polyene
    Super Member
    • Total Posts : 857
    • Reward points : 0
    • Joined: 2006/01/08 03:53:41
    • Location: Sweden
    • Status: offline
    RE: Indirect addressing ??? 2006/01/14 07:06:51 (permalink)
    0
    That's right.. But you should also insert a "clrf FSR0L" in the beginning to make sure that the low byte of the address is correct. Or even better, you can use the LFSR-instruction to load both bytes in one double-word instruction, instead of three single-word instructions, but this only works for fixed addresses. If you supply an adress through a pointer you need to write to FSR0L and FSR0H in two separate steps.
    #4
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Indirect addressing ??? 2006/01/14 07:30:56 (permalink)
    0
    ok, thanks. I'll try it.
    #5
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Indirect addressing ??? 2006/01/17 02:24:21 (permalink)
    0
    anyone pls help to check whether my coding is correct. i am using PIC18F252. i move some value in the memory using indirect addressing method then transmit it to my pc using the built in usart. but it seems that i cant receive any character at my pc. my TransmitSerial subroutine is working just fine for other coding. So i guess the problem is with the indirect addressing coding. thanks a lot.
     

       movlw   0x01
       movwf   FSR0H
       clrf    FSR0L
       movlw   0x42
       movwf   POSTINC0
       movlw   0x43
       movwf   POSTINC0
       movlw   0x44
       movwf   POSTINC0
       movlw   0x45
       movwf   POSTINC0
       movlw   0x46
       movwf   POSTINC0
     
       rcall    TransmitSerial
       movf     POSTDEC0
       rcall    TransmitSerial
       movf     POSTDEC0
       rcall    TransmitSerial
       movf     POSTDEC0
       rcall    TransmitSerial
       movf     POSTDEC0
       rcall    TransmitSerial
     

    #6
    ric
    Super Member
    • Total Posts : 22098
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    RE: Indirect addressing ??? 2006/01/17 02:46:45 (permalink)
    0
    movf     POSTDEC0

    You have ommitted the destination.
    I think it defaults to ",f" if you do, so it never reaches W.
    Add a ",w" to the instruction.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    RE: Indirect addressing ??? 2006/01/17 07:15:55 (permalink)
    0
    it works. thanks a lot.
    #8
    Jump to:
    © 2017 APG vNext Commercial Version 4.5