• AVR Freaks

Lookup table using RETLW

Author
leojose
Super Member
  • Total Posts : 291
  • Reward points : 0
  • Joined: 2004/04/15 07:22:39
  • Location: India
  • Status: offline
2004/11/03 07:59:46 (permalink)
0

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 >

***ljose***
#1

1 Reply Related Threads

    whsiung
    Super Member
    • Total Posts : 1461
    • Reward points : 0
    • Joined: 2003/11/07 12:44:35
    • Location: Malaysia
    • Status: offline
    RE: Lookup table using RETLW 2004/11/03 08:38:07 (permalink)
    0
    Hi Leo,

    Try this:


    ; with offset in W
    bcf WREG, 7
    rlnc WREG, f
    addwf PCL, f
    retlw ....
    ....


    Good luck.
    WH Tan

    Sorry, typing mistake.


    ; with offset in W
    bcf WREG, 7
    rlncf WREG, f
    addwf PCL, f
    retlw ....
    ....
    < Message edited by whsiung -- Nov. 3, 2004 11:41:45 PM >
    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5