This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can the preprossesor compute my const table?

Hello,

I want to protect the uC from having time intensitive computation while runtime. So i use some predefined const tables. As uC has only 8 kbyte RAM but 62 kbyte Programm_memory i have to chose Programm_memory.
I normaly write a old-fashioned Q-BASIC programm, which computes my table, converts numbers to hex and writes the whole stuff in a text-file like this one:

const unsigned short int my_weird_table[16384] =
{
0x07E9,0x07D4,0x078F,0x0774,0x0780,0x0788,0x0785,0x0785,
0x0786,0x0785,0x078C,0x0792,0x0797,0x07A2,0x07AC,0x07B2,
0x07BA,0x07C0,0x07C6,0x07CD,0x07D2,0x07D2,0x07CF,0x07B9,
0x078D,0x0764,0x0755,0x0767,0x078A,0x07AC,0x07CA,0x07E4,
0x07F3,0x07F2,0x07E7,0x07DC,0x07DA,0x07E2,0x07E9,0x07E4,
0x07D5,0x07C1,0x07AE,0x0798,0x0778,0x0751,0x0728,0x06FC,
0x06D2,0x06B1,0x069F,0x069F,0x06AC,0x06B4,0x06AB,0x0697,
0x068A,0x0691,0x06AB,0x06C7,0x06E6,0x0707,0x0719,0x0712,
0x06F6,0x06D1,0x06B3,0x0697,0x0662,0x0614,0x05DB,0x05C6,
0x05C0,0x05DE,0x0642,0x06DA,0x0769,0x07BD,0x07CB,0x079E,
,
,
0x07FE,0x0800,0x0802,0x0805,0x0807,0x0804,0x0803,0x0802,
0x0801,0x0801,0x0801,0x0800,0x0800,0x0800,0x0800,0x0800,
0xFFFF};


don't want to bore you, the computation part of my Q_Basic-programm can look like:

    If (X < (2 * PI) then
        Y = 1.5 * sin(X) + .75 * sin(2*X) + .05 * sin(5*X)
    else
        Y = sin(3*X)
    end if
    table(N) = 32768 * (1 + .5 * Y)


Now my idea: Isn't that a job, the preprossesor can do for me? I'am not sure about syntax, so i expect your suggestions very excited ;-)

0