Lookup table using RETLW
Hi all,
I have been trying to set up a look up table using the RETLW instruction for a couple of hours but I just can't get it to work correctly. It seems to pass the simulation test, but when I run it on the controller it kind of misbehaves. I think it is the manner that I am treating the PC registers.
I am posting the specific look up table here.
CALL COS_TABLE ;this instruction is somewhere in the Main routine
.
.
ORG 0x2000
COS_TABLE: ;
MOVFF PCL,TEMP ;to read the program counter in the PCLATH
MULLW .2 ;to create an offset
MOVF PRODL,W ;putting the calculated value back in WREG
ADDWF PCL,F ;adding the offset to the PCL
RETLW 0x01
RETLW 0x02
RETLW 0x03
RETLW 0x04
RETLW 0x05
.
.
.
I am using the PIC18f452
Kindly help...
Kind Regards.
< Message edited by leojose -- Nov. 3, 2004 1:03:16 AM >