Hallo

Dass dieser Code so übersetzbar ist kann ich schlichtweg nicht glauben. So könnte es vielleicht funktionieren:

Code:
 #include "RP6ControlLib.h"

int main(void)
{
   uint8_t i;
   initRP6Control();
	DDRA |= 4; // ADC2 (PA2) auf Ausgang schalten
	while(1)
   {
      for(i=0;i<100; i++) // 100 mal Impuls
      {
         PORTA |= 4;
         sleep(8);
         PORTA &= ~4;
         sleep(200-10);
      }
      for(i=0;i<100; i++) // 100 mal Impuls
      {
         PORTA |= 4;
         sleep(20);
         PORTA &= ~4;
         sleep(200-20);
      }

       for(i=0;i<100; i++) // 100 mal Impuls
       {
          PORTA |= 4;
        sleep(14);
        PORTA &= ~4;
        sleep(200-10);

          }
   }
   return(0);
}
Da ich aber kein M32 besitze kann ich es nicht testen...

Die Portbezeichnungen entsprechen den Zweierpotenzen. Pin0 ist 2^0 oder 1, Pin1 ist 2^1 oder 2, weiter gehts dann über 4, 8, 16, 32 und 64 bis 2^7 oder 128 für den achten Pin.

Dass der ADC2 beim Mega32 der Pin PA2 (Port A Pin2) ist, findet man im Datenblatt des Mega32 oder im Schaltplan des M32.

Gruß

mic

[Edit]
200-20 funktioniert natürlich. In der RP6-Library ist sleep() mit kleinem S definiert:

Code:
/**
 * Delay with the help of the 10kHz timer.
 * sleep(10) delays for *about* 1ms! Not exaclty, as we do not use assembly routines
 * anywhere in this library!
 *
 * This is a blocking routine, which means that the processor
 * will loop in this routine and (except for interrupts) the
 * normal program flow is stopped!
 * Thus you should use the Stopwatch functions wherever you can!
 *
 * Example:
 *		sleep(1); // delay 1 * 100us = 100us = 0.1ms
 *		sleep(10); // delay 10 * 100us = 1000us = 1ms
 *		sleep(100); // delay 100 * 100us = 10000us = 10ms
 *		// The maximum delay is:
 *		sleep(255); // delay 255 * 100us = 25500us = 25.5ms
 */
void sleep(uint8_t time)
{
	delay_timer = 0;
	while (delay_timer <= time+1);
}
(Aus RP6ControlLib.c)