If I use a data lookup table with PCL register I have to place the table in between the first 256 lines.
(Let say my program is having 1500 lines if I place the table in the end it wont work.)
Then what about the delay routines do I have place that also in the first 256 lines in my 1500 line program? Or can I place that in any location?
As long as the table is smaller than 256 bytes, you can place it in any 256 byte 'block', and just set the PCLATH bits accordingly - however, it's often easier (although only marginally) to just place the table in the first 256 bytes.
hi,
The easy way to get your table length, place it at the start of a block, compile it and look at the hex file.
Or you could count each instruction in your table code, look at the disassembly file this will also help.
>>> I have ten lines using RETLW XX.
I would suggest you use the PCLATH method, its a more general solution. As pommie has posted.
movlw high(Table)
movwf PCLATH
movlw low(Table)
addwf Pointer,W
btfsc STATUS,C
incf PCLATH,F
movwf PCL
Table DT "Hello World!",0
hi,
No, the high(table) value is the upper 5 bits of the PC, [address] and the low(table) is lower 8 bits of the PC [address]. Together they make the pointer to the character in the table.
Just for explanation. [not a real case]
Suppose the upper 5 bits were 00000 and the table started at 00000
then the first character would be at address 00000,0000,0000 and the
second char would be at 00000,0000,0001........ This is a poor example, but it may help you to get the idea.