PDA

View Full Version : What's the maximum number of elements in a table?



J. Mark Wolf
- 27th March 2011, 19:02
I need to store approx 300 words elements (600 bytes) in a table.

It looks like Lookup2 craps out at 256 words, and Lookup does the same at 256 bytes.

Any workarounds? (That EXT modifier looks kinda scary)

mark_s
- 27th March 2011, 21:23
I need to store approx 300 words elements (600 bytes) in a table.

It looks like Lookup2 craps out at 256 words, and Lookup does the same at 256 bytes.

Any workarounds? (That EXT modifier looks kinda scary)


One work around is to use two lookup2 statements. Placed one right after the other.

Example, 150 in each words table,


Gosub MYTABLE


MYTABLE:

If INDEX > 150 then MYTABLE2

LOOKUP2 INDEX, [1,....150],VAR

goto endtable

MYTABLE2:
INDEX = INDEX - 150

LOOKUP2 INDEX,[151...300],VAR

endtable:

Return

J. Mark Wolf
- 28th March 2011, 12:29
One work around is to use two lookup2 statements. Placed one right after the other.

Example, 150 in each words table,


Thanks Mark_S

I was able to re-scale the table down into 253 words and LOOKUP2 is fine with it.

So, is 256 words a hard limit for PB Pro?

mark_s
- 28th March 2011, 14:15
The holy manual says "Up to 255 (1024 for pic18fxxx) constants are allowed in the list" thats for Lookup.

Lookup2 it states "Up to 85(1024 for pic18fxxx) values are allowed in the list"

So, I guess it depends on what pic you are using 18f or 16f?

J. Mark Wolf
- 28th March 2011, 19:50
The holy manual says "Up to 255 (1024 for pic18fxxx) constants are allowed in the list" thats for Lookup.

Lookup2 it states "Up to 85(1024 for pic18fxxx) values are allowed in the list"

So, I guess it depends on what pic you are using 18f or 16f?

I saw that also, after creating my LOOKUP2 table, but I'm using the new 16F1827, and the compiler didn't start balking until I got over 255 or 256 words (can't remember which).

I whittled the table down to 253 words, and it's compiling fine. I figured there'd been an "undocumented capacity update" since the manual was last printed.

I haven't yet down loaded any code to the device so we will see what happens then.

J. Mark Wolf
- 29th March 2011, 01:33
The holy manual says "Up to 255 (1024 for pic18fxxx) constants are allowed in the list" thats for Lookup.

Lookup2 it states "Up to 85(1024 for pic18fxxx) values are allowed in the list"



I posed the question to tech support.

According to Darrel, the limit for LOOKUP2 and 16F parts has been bumped to 256 elements.

That's good news for my application!