Hallo zusammen,

ich habe ein RN-Mega2560 http://www.robotikhardware.de/download/rnmega2560.pdf und möchte in Bascom ein ca. 2 kHz starkes PWM Signal erzeugen. Dazu wollte ich den Timer1 benutzen.

Die Quarzfrequenz liegt bei 16000000

Der Timer1 ist ein 16 Bit Timer. Soviel ich weiß, kann man den 16 Bit Timer auch mit weniger Bit betreiben, um dass mal laienhaft auszudrücken.

Wenn ich den Prescaler auf 256 setzte und den Timer auf 14 Bit setze, erhalte ich 1,9 kHz. Allerdings bekomme ich beim komiplieren einen Fehler: Invalid parameter for config parameter or value [14]

Mein 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


Echo Off


Config Timer1 = Pwm , Pwm = 14 , Compare A Pwm = Clear Up , Prescale = 256     ' Stiftleiste JP 1; Pin 24




Led = 0                                                     ' LED einschalten


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


Motor1_rotational_direction = 1


Motor1_speed = 127
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  Do


' 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


  Loop


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End
Hat jemand eine Idee, ich muss ein ca. 2 kHz starkes PWM-Signal erzeugen. Nicht unbedingt mit Timer1.

Vielen Dank.

Grüße

datatom