Searching \ for '[PIC]: >256 byte Table' 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/memory.htm?key=table
Search entire site for: '>256 byte Table'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: >256 byte Table'
2000\06\29@103538 by smerchock, Steve

flavicon
face
Friends,

I know this question has been asked, and yes I looked at the
PICLIST FAQ. There was good info their, but I was hoping somebody could
explain a few things to me.

In MICROCHIPs application note AN556 "Implemeting a Table Read"
the code is as follows:

movlw           LOW   Table
addwf           offset
movlw           HIGH  Table
btfsc           status,c
addlw           1
movwf           PCLATH
movf            offset,w
call            Table
;
;
;
Table:
movwf           pcl
retlw           'A'
retlw           'B'
retlw           'C'
;
;
etc............


I know that "LOW" is taking the lower byte of "Table".
Problem is,..... what is "Table"? Do you equate it to a
number at the beginning of the program like:

Table           EQU     H'0200'

This will load 0x00 into "LOW" and 0x02 into "HIGH"?
Does it have to have the same name as the table of data?
Also, the register labeled "offset", is it some type of
register that is being incremented, decremented,...etc?

Thank you very much!!

Best regards,
Steve


Steven Kosmerchock
Radio Frequency Systems
Phoenix  Arizona  USA
http://www.rfsworld.com

www.geocities.com/researchtriangle/lab/6584

2000\06\29@111853 by James Paul

flavicon
face
Steve,

'TABLE' is a label.  It is at the begining of the data table below.
"OFFSET' is how deep into the table do you want to go.
For instance, in the table listed below, lets say you had the offset
at 2.  In this case, RETLW would return "C".
The reason for this is that at compile time, the compiler saw the
label 'TABLE', and set it's address to whatever.  This address can
be found several places, but I like looking at the listing file.
So when the table lookup routine is called, the PC is loaded with
the address of the label table.  Next it adds the 'OFFSET' to the PC
to come up with the final destination address.  And in this case,
that equates to final destination address points to 'C' in the table.
Is this clear to you now?  Basically what you have is the compiler
locates the table somewhere in memory, and the combination of the
base address plus the offset equals the element in the table you
want to retrieve.

Hope this helps you out.


                                          Regards,

                                            Jim


On Thu, 29 June 2000, "Kosmerchock, Steve" wrote:

{Quote hidden}

spam_OUTjimTakeThisOuTspamjpes.com

2000\06\29@115459 by Quentin

flavicon
face
Hi
You pretty much answer your own questions. I myself are not familiar
with HIGH and LOW directives, so I looked in the Help file:

8.5.1   Syntax
high  <operand>
low   <operand>
upper <operand>
8.5.2   Description
These operators are used to return one byte of a multi-byte label value.
This is done to handle dynamic pointer calculations as might be used
with table read and write instructions.
8.5.3   Example

movlw  low  size     ; handle the lsb's
movpf  wreg, low size_lo
movlw  high  size    ; handle the msb's
movpf  wreg,  high size_hi


> I know that "LOW" is taking the lower byte of "Table".
> Problem is,..... what is "Table"? Do you equate it to a
> number at the beginning of the program like:
>
"Table" in this example is a constant (_L_iteral) which is the start
address for your Table where you want to read the information from. This
constant is derived from the Label "Table". When MPASM does its thing,
it will do this:
> Table           EQU     H'0200'
If your Table sits at address H'0200", that is, (continue with your
example, I would put an ORG   H'0200' before "Table"). Then:
> This will load 0x00 into "LOW" and 0x02 into "HIGH"?
Yes.
> Does it have to have the same name as the table of data?
Yes, explained above, but not necessary. It could be any other constant.
In this case it is used to find the start address of your table.
> Also, the register labeled "offset", is it some type of
> register that is being incremented, decremented,...etc?
Yes, "Table" will be your start address, "offset" will be the ...erhm...
offset from that start address to the value you want to read. So you
load "offset" with the position/address for the value you want to read
in the Table.

Hope this helps
Quentin

2000\06\29@115503 by pandersn

flavicon
face
Guys.....

I've used a number of tables that cover 1024 bytes. I like to locate the
program in the first bank and the table in the second bank. I use the org
directive to set the location of the table. Example.... (R=DEC)

       org 1024
Table
       movwf   PCL
       fill    (retlw HIBIT),56
       org 1025+56
HL      fill    (retlw HLGT),9
       fill    (retlw HIBIT),19
       org 1025+84
GT3
       fill    (retlw K3),10

etc

Use org to set entries into the table
Use fill to put in constants from that point
Use the EQU to define those constants....if you want to change later and
NOT retype the table.

etc.

You'll have to modify the info presented in the APP NOTE you mention to
allow you to cover more than 256 entries (postions) into the table.

Use HIGH Table and LOW Table.

Hope that helps........

Phil Anderson.....




On Thursday, June 29, 2000 10:19 AM, James Paul [SMTP:.....jimKILLspamspam@spam@JPES.COM] wrote:
{Quote hidden}

2000\06\29@195036 by Tony Nixon
flavicon
picon face
I made a mistake with some code I posted yesterday and is ammended
below.

Table can access 1 to 8178 bytes (assuming max ROM of 8K)

Table   movlw High(TStart)
       movwf PCLATH
       movf OffsetH,W
       addwf PCLATH
       movlw Low(TStart)
       addwf OffsetL,W
       btfsc STATUS,C
       incf PCLATH

       movf OffsetL,W
       call DoTable

       movlw High(here)
       movwf PCLATH    ; reset PCLATH

here    goto here

       org 0x????

DoTable addwf PCL
TStart  Retlw d'0'
       etc


As an example of how to use it, say you want to output speech data at 5K
samples per second.
A simple R2R ladder is on PortB.
The speech table has 3000 data points


Start   clrf OffsetH
       clrf OffsetL

SoundLoop       ; 200uS loop time = 5000 samples per second

       movlw High(Table)
       movwf PCLATH
       call Table      ; get sound data
       movwf PORTB

       movlw High(here)
       movwf PCLATH    ; reset PCLATH

here    incf OffsetL    ; add 1 to data pointer
       btfsc STATUS,C
       incf OffsetH

NoUp    movlw Low(d'3000')
       xorwf OffsetL,W
       btfss STATUS,Z
       goto SoundLoop

       movlw High(d'3000')
       xorwf OffsetH,W
       btfss STATUS,Z
       goto SoundLoop
       goto Start
;
; SOUND DATA TABLE 3000 ELEMENTS
;
Table   movlw High(TStart)
       movwf PCLATH
       movf OffsetH,W
       addwf PCLATH
       movlw Low(TStart)
       addwf OffsetL,W
       btfsc STATUS,C
       incf PCLATH

       movf OffsetL,W
DoTable addwf PCL
TStart  DT "Hello. I'm Mr Ed"

; plus another 2984 data points

       end

PS: the text won't sound like that coming from PORTB ;-)

PPS if you want an easy way to create a 3000 point data table ready for
MPASM see

http://www.picnpoke.com/demo/dtimg.html

--
Best regards

Tony

http://www.picnpoke.com
.....salesKILLspamspam.....picnpoke.com

2000\06\30@155633 by Dmitry Kiryashov

flavicon
face
Hi Tony.

AFAIK it can be done in more straight way.

       call    Dispatcher
; will be returned here


Dispatcher:
       movlw   High    TStart
       addwf   OffsetH,W
       movwf   PCLATH

       movlw   Low     TStart
       addwf   OffsetL,W
       skpnc
       incf    PCLATH,F

       movwf   PCL     ;computed goto with right PCLATH

TStart:
       dt      data0,data1,data2,...   ;retlw's

WBR Dmitry.


{Quote hidden}

2000\06\30@163258 by Scott Dattalo

face
flavicon
face
On Fri, 30 Jun 2000, Dmitry Kiryashov wrote:

{Quote hidden}

And if you look closely, this IS 12 instructions!

I agree with you, Dmitry. This is the better way of doing it (and it's been
posted here several times before [and James probably has it stuffed down in one
of his web pages]).

Incidently, since we are talking about 18cxxx parts too, there are several ways
this code could be implemented. It could be left as is... But the table read and
writes allow you to pack the 8 bit data values into program memory more
efficiently. That is, the 14bit core data tables have 6-bits for the RETLW
instruction.


       movlw   LOW  TStart
       addwf   OffsetL,w
       movwf   tabptrl,a

       movlw   HIGH TStart
       addwc   OffsetH,w
       movwf   tabptrh,a

       clrf    tabptru,a

At this point, you can issue any table read instruction and get access to the
data. If you're accessing consecutive entries in the table then you could do
this:

       tblrd   *+
       movf    tablat,w,a


Successive accesses now don't have to go through the long part of initializing
the table pointer.

Scott


'[PIC]: >256 byte Table'
2000\07\02@192306 by Tony Nixon
flavicon
picon face
Alice Campbell wrote:
>
> Hi Tony,
>
> I laughing! ive been mulling for a while a little marble-
> sized thingie that consists of an 8-pin smd pic, tiny
> microphone, and thermal switch that you rig up to screech
> (once) when hot coffee is poured on it in a mug....
> and having the ability to have my IDE play blatting noises at
> me, what a concept....
> thanks,
>
> alice

Hi Alice,

Make sure you don't swallow it. It might make an awful scary sound
coming out the other end.


On Fri, 30 Jun 2000, Dmitry Kiryashov wrote:

> Hi Tony.
>
> AFAIK it can be done in more straight way.

It sure can - I'll remember it this time ;-)

--
Best regards

Tony

http://www.picnpoke.com
salesspamspam_OUTpicnpoke.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\07\02@233900 by Jinx

face picon face
> Alice Campbell wrote:
> >
> > Hi Tony,
> >
> > I laughing! ive been mulling for a while a little marble-
> > sized thingie that consists of an 8-pin smd pic, tiny
> > microphone, and thermal switch that you rig up to screech
> > (once) when hot coffee is poured on it in a mug....
> > and having the ability to have my IDE play blatting noises at
> > me, what a concept....
> > thanks,
> >
> > alice
>
> Hi Alice,
>
> Make sure you don't swallow it. It might make an awful scary sound
> coming out the other end.

Er, WHAT/WHO ? will be making the awful scary sound ?

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\07\02@235128 by Tony Nixon

flavicon
picon face
Jinx wrote:
{Quote hidden}

The little marble sized thingy!
--
Best regards

Tony

http://www.picnpoke.com
@spam@salesKILLspamspampicnpoke.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

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