Hat jetzt geklappt, danke für die Tipps.

Der Motor läuft jetzt mit 1,9 kHz. Ich meine er läuft jetzt fast rund.

Hier das Programm:
Code:
' PWM Testprogram
'''''$prog , 255 , &B11011100,
$prog , 255 , &B11011001,
$regfile = "m2560def.dat"
$hwstack = 82                                               '80
$framesize = 68                                             ' 64
$swstack = 68                                               '44


$crystal = 16000000                                         'Quarzfrequenz
$baud = 19200


Config Pind.5 = Output
Led Alias Portd.5

Config Pinc.0 = Output                                      ' Stiftleiste JP 2; Pin 3; PC0
Motor1_reset Alias Portc.0

Config Pinc.1 = Output                                      ' Stiftleiste JP 2; Pin 4; PC1
Motor1_rotational_direction Alias Portc.1

Dim Motor1_speed As Integer
Dim Motor1_max As Integer
Echo Off

' Bei dem Motortreiber 18V15 von Pololu liegt die PWM Frequenz (kHz) bei max. 40 kHz, siehe Doku des Motorboard auf Seite 3
' Formel zur kHz-Berechnung: Ausgangsfrequenz = (Quarzfrequenz/Prescale ) /(Timerauflösung*2)
' Quarzfrequenz = $crystal = 16000000
' Bei 16 Bit Timer: Prescale = 1, 8, 64, 256, 1024 für Timer1 Seite 164 der Doku für ATMEGA2560
' Bei 8 Bit Timer/ Counter2: Prescale = 1, 8, 32, 64, 128, 256 , 1024
' Timerauflösung = Bit, bzw. Pwm = 8, Bit ist dann 8. Mit dem Wert Bit wird die Zahl 2 hochgenommen => 2 hoch 8 = 256

' (16000000:1024):(256*2) = 30,517578125 kHz

' Timer1 ist ein 16 Bit Timer, wird in diesen Fall auf 8 Bit gesetzt.
'Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Prescale = 1024       ' Stiftleiste JP 1; Pin 24
' (16000000:1024):(256*2) = 30,517578125 kHz
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Prescale = 256       ' 3,814697265625  ' Stiftleiste JP 1; Pin 24

Timer1 = 14

Led = 0                                                     ' LED einschalten

Motor1_reset = 1
Waitms 1
Motor1_reset = 0
Waitms 1
Motor1_reset = 1

Motor1_rotational_direction = 1

Motor1_max = 0

Motor1_speed = 0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  Do

       If Motor1_max = 0 Then

       '''''''' Beschleunigen

         Motor1_speed = Motor1_speed + 1
' Der max. Wert von Compare1a liegt bei 2 hoch Bit-Wert => 2 hoch 8 = 256. Da ab 0 gezählt wird, ist der max. Wert für einen 8 Bit-Timer 255

         Compare1a = Motor1_speed                           ' Stiftleiste JP 1; Pin 24

         Waitms 50

         If Motor1_speed = 256 Then
           Motor1_max = 1
         ''''' Richtungswechsel
           Motor1_speed = 256
           Waitms 1
           Toggle Motor1_rotational_direction
         End If

       Elseif Motor1_max = 1 Then

       '''''''' Abbremsen
         Motor1_speed = Motor1_speed - 1

         Compare1a = Motor1_speed                           ' Stiftleiste JP 1; Pin 24

         Waitms 50

         If Motor1_speed = 1 Then
           Motor1_max = 0
           ''''' Richtungswechsel
           Motor1_speed = 256
           Waitms 5
           Toggle Motor1_rotational_direction
           Waitms 1
           Motor1_speed = 1
         End If

       End If

  Loop

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End