'data tables (sort of)'
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
Any suggestions? (Please let me know if I haven't been clear.)
> 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:
goto Start ; Start being the real start of your code
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
- New search...