Hello friends ,
I am trying to generate sine wave using digital resonator as mentioned in application note - SPRA708. In that note C-code is given as,
short output;
main()
{
int i;
const short A=0x7e66; /* A=(1.975/2 * 32768) */
short y[3]={0,0x1209,0}; /* (y0,y1,y2), y1=(0.1409*32768) */
for (i=0; i<40; i++)
{
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 = y[0];
}
}
Problem is that,
1) why author suggests to divide A=1.975 by 2 ?
2) why they multiply A with y[1] twice followed by 15 bit right shift ?