Also Festpunktarithmetik ist schon so eine sache.
Auf dem PC funktionieren diese berechnungen, aber im µC nicht. Ich vermute da ist irgendwo ein Überlauf, den ich nicht sehe.
Ich habe alle Typen entsprechend umgewandelt.
hier meine Festpunkt sinus aproximation:
Code:
const int16_t	W=180; 		//Winkel eines Halbkreises
const int16_t	W2=360;		//Winkel eines Vollkreises
const int16_t 	Wd2=90; 		//Winkel eines Viertelkreises  

int16_t sinus(int16_t x)					//Eingabe mit Skalierung 128 = 7 Festkommabits Ausgabe 14 festkommabits
{

	if((x>>7)>W) x=-x+(W<<7);						//x wird auf das Intervall [-W;W] normiert (aufgrund der Achsensymmetrie um x=0)
    if((x>>7)<-W) x=-x-(W<<7);

 	//Parabel
	const int16_t B = 182; //2^-13	//(4/W);		//linearer Formfaktor der Parabel
    const int16_t C = -259;//2^-21	//(-4/(W*W));	//quadratischer Formfaktor der Parabel
	
	long y=((B*x)>>6)+((((C*x)>>11)*x*signi(x))>>10);	//2^-14 //Funktionswert der einfachen Parabel
    
    //Parabel Korrektur
	const int16_t Q = 99;	//2^-7	//0.775;		//Linearfaktor der einfachen parabel
    const int16_t P = 29;	//2^-7	//0.225;		//Linearfaktor der quadrierten korektur Parabel

    y=((Q*y)>>7)+((((P*y)>>7)*y*signl(y))>>14);	//2^-14	//Endergebnis nach gewichteter Summenbildung
	
	return y;
}
mfg Warchild