This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I am using the the algorithm of IIR filter to generate a sine wave. However, in a debugging mode I see a triangle waveform in graph window. Any clues?
volatile short output[16]; main() { unsigned int counter = 0; const short A=0x7e66; /* A=(1.975/2 * 32768) */ short y[3]={0,0x1209,0}; /* (y0,y1,y2), y1=(0.1409*32768) */ for (;;) { y[0] = (((A*y[1])>>15) + ((A*y[1])>>15)) - y[2]; y[2] = y[1]; /* y2 <–– y1 */ y[1] = y[0]; /* y1 <–– y0 */ output[counter] = y[2]; if((counter % 16) == 15) { counter = 0; } else { counter++; } } }
Thanks,
Lukasz