Hallo nochmal das umstellen hatte zunächst geklappt und die einzelnen methoden in meinem jetzigen code funktionieren einzeln auch.
Wenn ich jedoch mein programm compiliere kommt folgende fehlermeldung mit unwichtigen Warnungen aber einem Error.

Klicke auf die Grafik für eine größere Ansicht

Name:	f.JPG
Hits:	13
Größe:	78,1 KB
ID:	21142

Der Code:

Code:
#include "asuro.h"


void Testfahrt(void)
{
  #define FULL_L 250
#define FULL_R 250

/* Motor vorwärts */
void MotorFwd(void)
{
  MotorDir(FWD,FWD);
  MotorSpeed(FULL_L,FULL_R);
}

/* Motor rückwärts */
void MotorRwd(void)
{
  MotorDir(RWD,RWD);
  MotorSpeed(FULL_L,FULL_R);
}

/* Motor rückwärts Links */
void MotorRwdL(void)
{
  MotorDir(RWD,RWD);
  MotorSpeed(FULL_L,0);
}

/* Motor rückwärts Rechts */
void MotorRwdR(void)
{
  MotorDir(RWD,RWD);
  MotorSpeed(0, FULL_R);
}

/* Motor stop */
void MotorStop(void)
{
  MotorSpeed(0,0);
}


  unsigned char t1, t2;

  while (1)
  {
    t1 = PollSwitch();
    t2 = PollSwitch();
    if (t1 == 0 && t2 == 0)         /* keine Taste */
    {
      MotorFwd();          /* vorwärts fahren */
      FrontLED(ON);
      BackLED(OFF,OFF);
    }
    else if (t1 && t2 && t1 == t2)
    {
      MotorStop();
      if (t1 & 0x07) /* Tasten links gedrückt? */
      {
        MotorRwdL();       /* Rückwärtskurve links fahren */
        FrontLED(OFF);
        BackLED(ON,OFF);
      }
      if (t1 & 0x38) /* Tasten rechts gedrückt? */
      {
        MotorRwdR();       /* Rückwärtskurve rechts fahren */
        FrontLED(OFF);
        BackLED(OFF,ON);
      }
      Msleep(1000);        /* 1 Sekunde fahren */
    }
  }
 while(1);
 return(0);
}



void Abgrund(void)
#define STOP 200
{
   unsigned int lineData[2];
   unsigned char running = 1;
   MotorDir(FWD,FWD);
   FrontLED(ON);
   Msleep(72);
   MotorSpeed(255,255);
   do
   {
      LineData(lineData);
      if ((lineData[0] < STOP) || (lineData[1] < STOP))
	  {
	     MotorDir(RWD,RWD);
         MotorSpeed(255,255);
         BackLED(ON,ON);
		 Msleep(230);
         running = 0;
      }
   }
   while (running==1);
   MotorDir(BREAK,BREAK);
   Programme();
}


void Rechteck(void)
{

while(1)
{
StatusLED(GREEN);
MotorDir(FWD,FWD);
MotorSpeed(255,255);
Msleep(1000);
BackLED(ON,ON);
StatusLED(RED);
MotorDir(BREAK,BREAK);
Msleep(230);
BackLED(OFF,OFF);
MotorDir(FWD,RWD);
MotorSpeed(255,255);
Msleep(220);

}
}

void Melodie(void)
{
  uint16_t i;                     //zähler
uint16_t data[2];       //odo
uint16_t zuf;            //zufall



//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------

//
// uint8_t zufall()
//
// Liefert eine 8Bit Pseudozufallszahl zurück,
// die Zahlenfolge wiederholt sich spätestens nach 65535 Aufrufen
//

uint8_t zufall()
{
        static uint16_t startwert=0x0AA;

        uint16_t temp;
        uint8_t n;
               
        for(n=1;n<8;n++)
        {
                temp = startwert;
                startwert=startwert << 1;
       
                temp ^= startwert;
                if ( ( temp & 0x4000 ) == 0x4000 )
                {
                        startwert |= 1;
                }
        }
       
        return (startwert);
}

//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------





// tone table: thanks to IVO

//Töne definieren - tiefere Töne brummen und scheppern
#define A4		440
#define B4		466
#define H4		493
#define C5		523
#define DES5	554
#define D5		587
#define ES5		622
#define E5		659
#define F5		698
#define GES5	740
#define G5		783
#define AS5		830
#define A5		880
#define B5		932
#define H5		987
#define C6		1046
#define DES6	1108
#define D6		1174
#define ES6 	1244
#define E6		1318
#define F6		1396
#define GES6	1479
#define G6		1567
#define AS6		1661
#define A6		1760
#define B6		1864
#define H6		1975
#define C7		2093
#define DES7	2217
#define D7		2349
#define ES7		2489
#define E7		2637
#define F7		2793
#define GES7	2959
#define G7		3135
#define AS7		3322
#define A7		3520
#define H7		3729
#define B7		3951

#define HALF 300
#define FULL 600
#define _OFF 0
#define STOP 0


uint16_t duck_melody[]={
	C5,HALF,
	D5,HALF,
	E5,HALF,
	F5,HALF,
	G5,FULL,
	_OFF,HALF,
	G5,FULL,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	G5,FULL,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	A5,HALF,
	_OFF,HALF,
	G5,FULL,
	_OFF,HALF,

	F5,HALF,
	_OFF,HALF,
	F5,HALF,
	_OFF,HALF,
	F5,HALF,
	_OFF,HALF,
	F5,HALF,
	_OFF,HALF,
	E5,FULL,
	_OFF,HALF,
	E5,FULL,
	_OFF,HALF,

	D5,HALF,
	_OFF,HALF,
	D5,HALF,
	_OFF,HALF,
	D5,HALF,
	_OFF,HALF,
	D5,HALF,
	_OFF,HALF,

	C5,FULL,
	_OFF,HALF,

	STOP,STOP
};

uint16_t unknown_melody[]={
	G5,FULL,
	G5,FULL,
	A5,HALF,
	G5,HALF,
	C6,HALF,
	H5,HALF/2,
	G5,FULL,
	G5,FULL,
	A5,HALF,
	G5,HALF,
	D6,HALF,
	C6,HALF/2,
	G5,FULL,
	G5,FULL,
	G6,HALF,
	E6,HALF,
	C6,FULL,
	C6,FULL,
	H5,HALF,
	A5,HALF,
	F6,FULL,
	F6,FULL,
	E6,HALF,
	C6,HALF,
	D6,HALF,
	C6,HALF/2,

	STOP,STOP
};

uint16_t schwebung1[]={
	C5,1000,
	C5,1000,
	C5,1000,
	C5,2000,
	STOP,STOP
};
uint16_t schwebung2[]={
	D5,1000,
	E5,1000,
	F5,1000,
	G5,2000,
	STOP,STOP
};


/***************************************************************************
*	void StereoSound(uint16_t *noten1, uint16_t *noten2)
*	
*	use two motors as loudspeaker and create a sound on each motor
*
*   input
*	noten1,noten2: 	tables with tone pitch and duration
*
***************************************************************************/
#define FS 31250 // controlled by timer2 8Mhz/256

void StereoSound(uint16_t *noten1, uint16_t *noten2)
{
	uint16_t index1=0,index2=0;
	uint16_t timer1,timer2;
	uint16_t phase1,phase2,angle1,angle2;
	uint8_t dir1=FWD,dir2=FWD;
	uint8_t speed1,speed2;

	angle1=(uint32_t)noten1[index1++]*65536/FS;
	timer1=noten1[index1++]*(FS/1000);		
	if(angle1==0)speed1=0;
	else speed1=255;

	angle2=(uint32_t)noten2[index2++]*65536/FS;
	timer2=noten2[index2++]*(FS/1000);		
	if(angle2==0)speed2=0;
	else speed2=255;

	MotorSpeed(speed1,speed2);

	
	
	cli(); // stop all interrupts





	while(timer1!=0)
	{
		
		
		timer1--;
		timer2--;
		
		
		if(timer1==0) 
		{
			angle1=(uint32_t)noten1[index1++]*65536/FS;	
			timer1=noten1[index1++]*(FS/1000);
			if(angle1==0)speed1=0;
			else speed1=255;
				
			MotorSpeed(speed1,speed2);

		
			if ( angle1 > 0 )
			{
			//links an
			PORTC |=(1<<PC1);
			}
		
			else 
			//links aus   
			{
			PORTC &=~(1<<PC1);
			}



			//statusLED

		zuf = zufall();                     // Zufallszahlen zw. 0 und 255
		zuf = zuf * 3;                      // 255 510 765

		if ((zuf > 510))   
			{
			StatusLED(RED);
			}
		else if ((zuf > 255) && (zuf <= 510))   
			{
			StatusLED(YELLOW);
			}
		else if (zuf <= 255)   
			{
			StatusLED(GREEN);
			}


		
		
		if(timer2==0) 
		{
			angle2=(uint32_t)noten2[index2++]*65536/FS;	
			timer2=noten2[index2++]*(FS/1000);
			if(angle2==0)speed2=0;
			else speed2=255;			
							
			MotorSpeed(speed1,speed2);

			if ( angle2 > 0 )
			{
			//rechts an
			PORTC |=(1<<PC0);
			}
		
			else 
			//rechts aus   
			{
			PORTC &=~(1<<PC0);
			}
		}

		
		


		}
		
		if(timer2==0) 
		{
			angle2=(uint32_t)noten2[index2++]*65536/FS;	
			timer2=noten2[index2++]*(FS/1000);
			if(angle2==0)speed2=0;
			else speed2=255;			
							
			MotorSpeed(speed1,speed2);

			
		}
			
		

		phase1+=angle1; 
		
		if(phase1&0x8000) dir1=FWD;
		else dir1=RWD;
		
		phase2+=angle2; 
		
		if(phase2&0x8000) dir2=FWD;
		else dir2=RWD;
		MotorDir(dir1,dir2);
		
		// sync with Timer2 ( 31250Hz )
		while(!(TIFR&(1<<TOV2)));
		TIFR|=TIFR&(1<<TOV2);
	}

	
	MotorSpeed(0,0); 
	sei(); // enable all interrupts
}





	// 1 sec "Anfangs-Zufallszahl" 
  	StatusLED(OFF);
  	BackLED(OFF,OFF);

  	Msleep(1000);

	StatusLED(OFF);
	BackLED(ON,ON);
	
	DDRC = (1<<PC1);
  	DDRC |= (1<<PC0);
	PORTC=(1<<PC1);
	PORTC |=(1<<PC0); 

	// One voice on two notors
	StereoSound(duck_melody,duck_melody);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	// Two voices, one on each Motor
	StereoSound(duck_melody,&duck_melody[4]);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);


	// Two voices, one on each Motor
	StereoSound(duck_melody,&duck_melody[6]);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	// Two voices, one on each Motor
	StereoSound(duck_melody,&duck_melody[8]);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	// One voice on two notors
	StereoSound(unknown_melody,unknown_melody);
	
	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	// Two voices, one on each Motor
	StereoSound(unknown_melody,&unknown_melody[6]);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	// Two different melodies
	StereoSound(unknown_melody,duck_melody);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	StatusLED(OFF);
	StereoSound(schwebung1,schwebung2);

	StatusLED(OFF);
	PORTC=(0<<PC1);
	PORTC |=(0<<PC0);
	Msleep(1000);

	StatusLED(Green);

	Programme();	



}

void Programme (void)
{
  unsigned char sw;
  SerPrint("Hello I am ASURO");
  for (;;)
  {
    sw = PollSwitch();
    if (sw == 0x01) Melodie();
    if (sw == 0x02) Abgrund();
    if (sw == 0x04) Rechteck();
    //if (sw == 0x08) L2();
	//if (sw == 0x16) L3();
	//if (sw == 0x32) L4();
  }
}


int main(void)
{
  unsigned int  i,data[2];
  unsigned char count = 0,flag = 0;
  Init();

  for (i = 0; i < 0x1FFF; i++)
  {
    OdometrieData(data);
    if ((data[0] <  200) && (flag == 1))
    {
      count ++;
      flag = 0;
    }
    if (data[0] >= 600) flag = 1;
  }
  if (count > 10) Programme();

 /* while (1)
  {
    if (PollSwitch())
    {
      while (PollSwitch());
      Programme();
    }
*/	else
   Testfahrt();
   
//  }
  
  return 0;
}