Connect with us

How to create a lookup table

Discussion in 'Microcontrollers, Programming and IoT' started by rob_croxford, Oct 19, 2010.

  1. rob_croxford

    rob_croxford

    262
    0
    Aug 3, 2010
    Hi all,

    I am trying to figure out how to create a look up table using the C language to run within my program. I have looked on the web however i have had no luck in finding a turorial or steps on how to achieve this. Im not sure if it is possible to use Excel to create this table (as is possible with assembly language)

    If anyone could give a few pointers or if you know of a good tutorial for this i would be very greatfull.

    Thanks

    Rob

    P.s. the table would only need 256 values to set an apropriate delay after reading the 8 bit ADC - unfortunatly my program at the moment is a bit large and runs rather slow. cheers
     
    Last edited: Oct 19, 2010
  2. LTX71CM

    LTX71CM

    182
    0
    May 23, 2010
    What you want is an array. "C Array Example" or "C Lookup Table" typed in to Google will surely be of help.

    Code:
    const unsigned char MyTable[256]={value0,value1,value2,etc..};
    
    Delay(MyTable[ReadADC()]);
    
     
  3. rob_croxford

    rob_croxford

    262
    0
    Aug 3, 2010
    Ahh ok so i simply write the table within my program making sure to keep it static??

    I will give it a go, no doubt i will have more questions soon! lol

    Cheers
     
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

-