Searching \ for '[PIC]: 18F4520 Indirect Addressing' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=18F
Search entire site for: '18F4520 Indirect Addressing'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 18F4520 Indirect Addressing'
2005\09\14@162401 by luis

flavicon
face
Hi all.
I4m working on indirect addressing for the first time in the 18F4520.
And I've got a few questions.
When I was working in the 16F series my code is this:

   movlw 0x20
   movwf FSR

lp_rec:
   btfss PIR1,RCIF
   goto $-1

   movf RCREG,W
   movwf INDF

end_of_rec:
   movlw 0x0D
   xorwf INDF,W
   bz GET_DATA ;received all the datas
   incf FSR,1
   goto lp_rec

How could I do the same on the 18F4520?
Thanks in advanced!

Luis F.


2005\09\14@163849 by Jan-Erik Soderholm

face picon face
luis wrote :

> Hi all.
> I4m working on indirect addressing for the first time in the
18F4520.
> And I've got a few questions.
> When I was working in the 16F series my code is this:

[snipped old 16F code...]

> How could I do the same on the 18F4520?

You could start with showing what you have tried
so far. Then we have something to begin with...

It's not that different. Different names on the registers...

Regards,
Jan-Erik.



2005\09\14@165301 by luis

flavicon
face
Yes Jan, of course.

I´ve done like this, but did not work yet.

   movlw 0x70
   movwf FSR0L

WAIT:
   btfss PIR1,RCIF
   bra WAIT

SAVE_BUF:
   movf RCREG,W
   movwf INDF0
   incf FSR0L,1 ;

   movlw 0x0D
   xorwf INDF0,W
   btfsc STATUS,Z
   bz GET_DATA ;
   bra WAIT

Best Ragards

Luis F.

{Original Message removed}

2005\09\14@171513 by Jan-Erik Soderholm

face picon face
luis wrote :

> I´ve done like this, but did not work yet.

What is *supposed* to happen ???
And what *does* happen ?

There is not a single comment in the code, so
it's not easy to tell what *your* intention with
the code was.

Anyway, search the datasheet for POSTINC.
That will save you an instruction, even if it
will not make it "work", whatever that is... :-)

Jan-Erik.


{Quote hidden}

2005\09\14@172751 by olin piclist

face picon face
luis wrote:
> I4m working on indirect addressing for the first time in the 18F4520.
> And I've got a few questions.
> When I was working in the 16F series my code is this:
>
> ...
>
> How could I do the same on the 18F4520?

You start by reading the manual.

The PIC 18 has 3 pointer registers FSR0 - FSR2.  They are 12 bits wide so
there are no longer indirect banks.  There are also various pre/post inc/dec
modes.  Again, see manual.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

2005\09\14@173333 by olin piclist

face picon face
luis wrote:
> I´ve done like this, but did not work yet.
>
>     movlw 0x70
>     movwf FSR0L
>
> WAIT:
>     btfss PIR1,RCIF
>     bra WAIT
>
> SAVE_BUF:
>     movf RCREG,W
>     movwf INDF0
>     incf FSR0L,1 ;
>
>     movlw 0x0D
>     xorwf INDF0,W
>     btfsc STATUS,Z
>     bz GET_DATA ;
>     bra WAIT

Come back after you've read the manual.  In particular the section called
"Indirect Addressing, INDF and the FSR Registers".  In my copy of the 18Fxx2
data sheet that's section 4.12 on page 50.  It's probably in a different
place in different data sheets, but can't be that hard to find if you
actually try.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.co

2005\09\14@175258 by Jinx

face picon face
>     movlw 0x70
>     movwf FSR0L

FSRs on the 18F are 16-bit, so you have to know what's in
FSR0H as well. The LFSR instruction takes care of the whole
address, eg LFSR FSR0,0x70, LFSR FSR0,Rx_bytes  etc

>     movwf INDF0
>     incf FSR0L,1 ;

MOVWF POSTINC0

2005\09\14@183020 by John Temples

flavicon
face
On Thu, 15 Sep 2005, Jinx wrote:

>>     movwf INDF0
>>     incf FSR0L,1 ;
>
> MOVWF POSTINC0

Not only is MOVWF POSTINC0 using one less instruction, it does more.
INCF FSR0L will not increment FSR0H if FSR0L rolls over; MOVWF
POSTINC0 will.

--
John W. Temples, III

2005\09\15@092627 by luis

flavicon
face
Thanks all that help me.
Now I got this. See a part of my code.

   lfsr FSR0, 0x70 ;start  array

REC:btfss PIR1,RCIF ;RECEIVED DATA USART?  
   bra REC

SAVE_BUF:
   movf RCREG,W
   movwf TEMP0    ;SAVE DATA USART
   xorlw 0x0D     ;GET ALL THE DATAS?
   bz GET_ALL     ;YES
   movf TEMP0,W
   movwf POSTINC0 ;ACCESSES FSR VALUE AND INC IT
   bra REC

GET_ALL:
   lfsr FSR0, 0x70 ;start array

LP_SHOW:
   movf INDF0,W
   xorlw 0x0D
   btfsc STATUS,Z
   return            ;RET ROUTINE
   movf INDF0,W
   call SEND_CHAR    ;SHOW DATAS LCD
   clrf POSTINC0     ;CLR FSR VALUE AND INC IT
   bra LP_SHOW

Best regards

Luis F.

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...