Searching \ for '[PIC:] Entries in a look-up 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: 'Entries in a look-up table'.

Exact match. Not showing close matches.
PICList Thread
'[PIC:] Entries in a look-up table'
2001\01\17@182719 by Jose S. Samonte Jr.

picon face
Sirs, how many entries could a lookup table have in a PIC16F84? What is the
maximum number of entries?
Thank you very much and God Bless.

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\17@184208 by Christian Dorner

flavicon
face
Hi!

> Sirs, how many entries could a lookup table have in a PIC16F84? What is
the
> maximum number of entries?

255.

Descripted in the datasheet in section 4.3.1 you have to care about the 256
word block cause the PCLATH will NOT been corrected on a computed jump.

Why 255? 1 Word for the "addwf PCL,f" and 255 word's rest for your table.
Take care to set the ORG to a 0x?00 adress to avoid overlapping the 256 word
blocks.

cu, Doc ...

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\17@185204 by Tony Nixon

flavicon
picon face
Christian Dorner wrote:
{Quote hidden}

I would imagine you could have as many as would fit, minus the
application itself, and the overhead for the multi-page table call.

--
Best regards

Tony

mICro's
http://www.picnpoke.com
spam_OUTsalesTakeThisOuTspampicnpoke.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\17@193356 by Christian Dorner

flavicon
face
> I would imagine you could have as many as would fit, minus the
> application itself, and the overhead for the multi-page table call.

Yes, you're right! It's possible to expand the table with dealing the PCLATH
or to jump between several tables around to expand. (I use this in my
current application to load the text for several display messages.)

But you have still to care about the 256 word block for computed gotos - the
base of (maybe) every lookup table.

Please correct me if i went wrong.

cu, Doc ...

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\17@202157 by Drew Vassallo

picon face
>But you have still to care about the 256 word block for computed gotos -
>the
>base of (maybe) every lookup table.
>
>Please correct me if i went wrong.

We just dealt with this today!  There is no "magic limit" of 256 bytes.  The
program memory for a '84 is 1024 bytes, so you can have 1024 table values
minus any code used for any program function and table calls:

;; Call with location to retrieve in "Table_Position"
Get_Table_Value
                movlw  high (Table_Start)
                movwf  PCLATH
               movf    Table_Position, 0
               addlw   Table_Start
               skpnc
               incf    PCLATH, 1
               movwf   PCL
Table_Start
dt "Put table values here"


Don't make me send this again :)

--Andrew

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\18@073757 by Roman Black

flavicon
face
Christian Dorner wrote:
>
> > I would imagine you could have as many as would fit, minus the
> > application itself, and the overhead for the multi-page table call.
>
> Yes, you're right! It's possible to expand the table with dealing the PCLATH
> or to jump between several tables around to expand. (I use this in my
> current application to load the text for several display messages.)
>
> But you have still to care about the 256 word block for computed gotos - the
> base of (maybe) every lookup table.
>
> Please correct me if i went wrong.


Hey I want to confirm something here! :o) I am about to use
a 256 byte table for the first time (I have used smaller
ones often), and I was going to put the entire 256 words
in one block, and put the "addwf PCL,f" in the word
preceding it.

So will this work?? Obviously I will have set PCLATH
to the correct block for the table data itself.
-Roman

--
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


2001\01\18@101609 by Don Hyde

flavicon
face
If you are dedicating a 256-byte block to a table, then you don't need to do
the addwf, but can use a mov:

;This can be anywhere in memory (except where the table is, of course)
; input is in table_index
; result is returned in result

Table_Lookup:
       movlw   high table
       movwf   PCLATH          ;This selects the right 256-byte block
       movfw   table_index
       movwf   PCL                     ;And this goes to the correct table
entry
; This move acts like a goto...

; The retlw in the table returns to the location where Table_Lookup was
called from...
; Be careful in the calling code in machines with more than one page of
program memory because
; PCLATH will have been modified, and will affect all goto's and call's

;If I have one or more 256-byte tables in a program, I start them at the
"back" end of the memory
;placing them using org's.  That way, the code can grow, and when it bumps
into the tables you
;will get an assembler error.

org     0x??00  ;Where ?? selects some otherwise-unused 256-byte block of
program memory
table:
       retlw   1
       retlw   2       ;This is starting out to be a very boring table...
       ...
       ...
       ...



> {Original Message removed}

2001\01\18@105748 by Roman Black

flavicon
face
Thanks for the help Don, and well written too. That will
be even more useful to me than a fixed addwf table lookup
as I can access it from different parts of the program.
(without using an extra stack level)... Very nice!

So the retlw will take it back to the exit of the
calling routine?? If I understand this? As it will
ret based on the stack? I think this will suit my needs
also! :o)
-Roman




Don Hyde wrote:
{Quote hidden}

--
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


2001\01\18@114001 by Don Hyde

flavicon
face
For clarity, I should have included a sample call:

       movlw   d'23'           ;gonna lookup whatever 23 might mean...
       movwf   table_index
       call    Table_Lookup
;               <---------------  Returns to here with 23 translated via
table...


> {Original Message removed}

2001\01\18@173409 by Andrew Warren

flavicon
face
Roman Black <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> I am about to use a 256 byte table for the first time .... and I
> was going to put the entire 256 words in one block, and put the
> "addwf PCL,f" in the word preceding it.
>
> So will this work?? Obviously I will have set PCLATH to the correct
> block for the table data itself.

Roman:

Yes, that will work fine.

-Andy


=== Andrew Warren --- aiwspamKILLspamcypress.com
=== Staff Systems Engineer, IPD
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation.

--
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 2001 , 2002 only
- Today
- New search...