Connect with us

I need to PIC your knowledge. Please read.

Discussion in 'Electronic Basics' started by Me, May 1, 2007.

Scroll to continue with content
  1. Me

    Me Guest

    Hi all,

    Firstly: Thank you all for your help.
    Secondly:
    I'm having trouble trying to use a lookup table.
    I have found a tutorial that shows how, but the test for validity is for a 16 line table.
    Thats easy, AND the variable with 16, but what if I only have 9 lines in my table?
    ANDing my variable with 9 is not going to give me the wanted result is it?
    Or an I missing something?

    Thanks.
     
  2. Randy Day

    Randy Day Guest


    You're right, it won't.


    ; air code - I *may* have the values
    ; backwards for setting up the subtraction.
    ; run thru Sim before use

    MOVLW
    0x09
    MOVWF
    TEMPREGISTER
    ; save '9' to memory
    MOVF
    TABLEINDEX, 0 ; get your table index into W
    SUBWF
    TEMPREGISTER, 1 ; subtract your index from 9
    BTFSS
    STATUS, 0 ; if CARRY/BORROW set, index>9, skip

    CALL GET_FROM_TABLE ; if number<=9, subroutine

    ; is called, index is in W
     
  3. Depending on the PIC, you may need to watch out for crossing page
    boundaries. You can check for address overflow, and adjust PCLATH. You can
    also use ORG to set the table at a memory location that does not cross a
    page boundary.

    See AN556 for Table Read.

    Paul
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-