Lookup table using RETLW
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
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
I am using the PIC18f452
< Message edited by leojose -- Nov. 3, 2004 1:03:16 AM >