Maker Pro
Maker Pro

How to create a lookup table

rob_croxford

Aug 3, 2010
262
Joined
Aug 3, 2010
Messages
262
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:

LTX71CM

May 23, 2010
182
Joined
May 23, 2010
Messages
182
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()]);
 

rob_croxford

Aug 3, 2010
262
Joined
Aug 3, 2010
Messages
262
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
 
Top