avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Help with flash lookup table


From: Micah Carrick
Subject: [avr-gcc-list] Help with flash lookup table
Date: Wed, 10 May 2006 12:42:10 -0700
User-agent: Thunderbird 1.5.0.2 (X11/20060501)

I'm a bit new to this. I'm trying to use a lookup table in flash memory to determine the distance from the ADC from a GP2D120 distance sensor. I basically have this:

static uint8_t gp2d120_data[] PROGMEM = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,30,29,28, 27,26,25,25,24,24,24,23,23,23,22,22,21,20,20,19,19,19,19,18,18,18,17,17, 17,16,16,16,15,15,15,15,15,14,14,14,13,13,13,13,13,13,12,12,12,12,12,12, 11,11,11,11,11,11,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8, 8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
};

uint8_t gp2d120_adc8_to_cm (uint8_t adc_value)
{
       uint8_t *ptr = gp2d120_data;
       *ptr += adc_value;
return pgm_read_byte(ptr);
}

I believe my function there isn't quite right. Can someone point me in the right direction?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]