Searching \ for 'data tables (sort of)' 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/mems.htm?key=data
Search entire site for: 'data tables (sort of)'.

Truncated match.
PICList Thread
'data tables (sort of)'
1998\02\01@184113 by Williamson

flavicon
face
My program needs to send many bytes of hex data.  I thought I could use
the DATA or DT commands, but now I don't know.  I cannot use RETLW because
I need to return more than one byte (up to 128 bytes).

The way I am thinking of implementing it is by indirect addressing.
That is, by loading the base address of the "transmit block" into
FSR and incrementing until I get to the end of the block.  I guess
I just don't know how to "dump" hex data into the program memory
using MPLAB.

Any suggestions?  (Please let me know if I haven't been clear.)

Thanks,

Jason

1998\02\02@022119 by John Payson

picon face
> My program needs to send many bytes of hex data.  I thought I could use
> the DATA or DT commands, but now I don't know.  I cannot use RETLW because
> I need to return more than one byte (up to 128 bytes).

What you need to do most likely is to use a "table" of RETLW instructions.
Assuming all of your data tables will fit in 255 bytes or less and you're
using one of the 1K or 2K-word 14-bit parts, I'd suggest you write your
code like this:

Addr0:
       goto    Start   ; Start being the real start of your code

Table1:
       addwf   PC
       retlw   data
       retlw   moredata
       ...
       retlw   lastdataoftable1
Table2:
       addwf   PC
       retlw   data
       retlw   moredata
       ...
       retlw   lastdataoftable2

...
Start:
       clrf    Status
       clrf    PCLATH
       ...

And then when you need to read an item from one of your tables, just use
"CALL TABLEn" [or whatever label you gave it] with the desired index in W.
If W is zero, the first table entry will be returned; if it's one, then
the second entry will be returned.  Be aware that if W is too big, the
code may wander off into space so you should be careful.

If you need more than 255 bytes' worth of tables, or if you are using more
than 2K of code altogether then you need to worry about putting correct
values in PCLATH; for your first project, though, I'd suggest avoiding
that until you get used to doing tables on the PIC.  It's a little wierd,
having to use RETLW to handle tables, but it does in fact work which is
in the end what counts.

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