I have developed some code to implement the look-up table in C, but I'm still having some issues.
The code should create a 256 byte array, populate it with delay times in micro seconds and then stick it in program memory for me to refrence based on ADC byte outputs.
Each ADC byte output would correspond to a delay time in the lookup table.
Can someone tell me what I'm doing wrong as the code wont compile.
Thanks for your time
N.B: even the for loop part is throwing an identifier error. I'm stumped
int table [256];
int i;
for (i=0; i<256; i++)
able=((1/120000000)-(1/120000000*i/255)); //lookup table values
const int table= delay_table; //create lookup table in memory
///////////////////////////////////////////////////////////////////////////////
void main (void)
{
ADCON0=0x02; // start A/D conversion
do{} // crude polling of GO/DONE bit to see when it gets
while (ADIF!=1); //cleared which indicates ADC is complete
ADIF=0;
int dig_controlvol;
dig_controlvol=ADRESH; //pass adc result to variable
dim_delay=delay_table[dig_controlvol]; //ADC result corresponds to lookup table time in us
}
The code should create a 256 byte array, populate it with delay times in micro seconds and then stick it in program memory for me to refrence based on ADC byte outputs.
Each ADC byte output would correspond to a delay time in the lookup table.
Can someone tell me what I'm doing wrong as the code wont compile.
Thanks for your time
N.B: even the for loop part is throwing an identifier error. I'm stumped
int table [256];
int i;
for (i=0; i<256; i++)
able=((1/120000000)-(1/120000000*i/255)); //lookup table values
const int table= delay_table; //create lookup table in memory
///////////////////////////////////////////////////////////////////////////////
void main (void)
{
ADCON0=0x02; // start A/D conversion
do{} // crude polling of GO/DONE bit to see when it gets
while (ADIF!=1); //cleared which indicates ADC is complete
ADIF=0;
int dig_controlvol;
dig_controlvol=ADRESH; //pass adc result to variable
dim_delay=delay_table[dig_controlvol]; //ADC result corresponds to lookup table time in us
}