Jump to content

Can I do 'normal' table lookups in MIOS ?


DriftZ
 Share

Recommended Posts

Hi, I been trying to do some table lookup but somehow I cannot get it to work. Is there something in MIOS that requires special attention todo these things ?

Or maybe it is just my lack of knowledge :(

I been looking thru following documents concerning TBLRD & stuff, but I didn't get much wiser.

http://www.microchip.com/download/lit/suppdoc/refernce/golden/indgate/39508.pdf

ftp://ftp.microchip.com/download/faqs/example/18cxxx/table.zip

I even tried it with the 'old style' RETLW & PCL things... no success either... I just can't read the correct data.

Or perhaps could anyone provide me with an example of the simplest table lookup that works in MIOS ?

thanks a bunch

Link to comment
Share on other sites

Hi DriftZ,

there are some simple examples in the SID application, see:

sid_sin_table.inc (reading one entry from a table)

sid_lfo_table.inc (reading two entries from a table)

retlw and PCL isn't working properly on a PIC18F, you have to use the JUMPTABLE_2BYTES macro instead:

MY_INCFILE_GetValue
        JUMPTABLE_2BYTES 8 ; entries
        retlw 0x01
        retlw 0x42
        retlw 0x03
        retlw 0x74
        retlw 0x35
        retlw 0x23
        retlw 0x84
        retlw 0x23

the GetValue function has to be called in order to get the return value. However, table reads are more elegant.

Best Regards, Thorsten.

Link to comment
Share on other sites

you have to use the JUMPTABLE_2BYTES macro instead

Huray! :)

This works, splendid, thanks !

I did have a look at the SID tables, but I found so many 'extra' instructions in there, too much for me to filter out the essentials... I still have to learn alot !

cheerz

Oh btw, about tablereads... perhaps more elegant but nowhere explained on a newcomers level  :-/

(e.g. the example by microchip isn't exactly drowning in explanatory commenting, is it ?)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...