Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted
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 ?)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...