Quote:
|
Originally Posted by Kevin Watson
Yes, EEPROM is a great place to locate, for example, trigonometric lookup table(s). A little piece of of code like this:
Code:
#include <math.h>
#include "eeprom.h"
unsigned int i;
unsigned char data;
//create a zero to ninety degree lookup table
for(i=0; i<=90; i++)
{
// wait, if necessary, for a free slot on the circular queue
while(EEPROM_Queue_Free_Space() == 0);
// normalize the output to the maximum value a byte variable can hold
data = (unsigned char)(255.0 * sin((float)i * 3.14159 / 180.0));
EEPROM_Write(i, data);
}
will generate one quadrant of a sine lookup table in EEPROM. Execute the code and you'll have a semi-permanent table in EEPROM that will allow you to very quickly solve sin(x) and cos(x).
-Kevin
|
Ugh, I just realized this code will cause the red-light-of-death. Anyone care to venture a guess as to why it won't work? I'll post corrected code tomorrow-ish.
-Kevin