kopy
01.03.2010, 11:53
Hallo, ich bin dabei mir eine RC Fernsteurung mit dem 2,4 Ghz Jeti Modul selber zu bauen. Leider habe ich immer noch das Problem das meine Timer nicht so ganz stabil laufen. Die Servos zucken immer wieder mal und das Signal auf dem Oszi sieht dementsprechend aus. Kann mir jemand sagen was ich da falsch mache??
$regfile = "m32def.dat" : $crystal = 8000000
'---------------------------- Timer konfigurieren ----------------------------
Config Timer2 = Counter , Prescale = 1024 , Clear Timer = 1
On Oc2 Timer2_isr:
Ocr2 = 190
Config Timer1 = Counter , Prescale = 8 , Clear Timer = 1
On Oc1a Timer1_isr
'---------------------------- Interrupts einschalten -------------------------
Enable Oc1a
Enable Oc2
Start Timer0
Enable Interrupts
'---------------------------- Konstanten -------------------------------------
Const Us300 = 300 '63536
Const Us1200 = 1200 '55536
'---------------------------- Variablen RX -----------------------------------
Dim Pulslaenge(20) As Word
Dim Ti As Byte
Dim I As Byte
' - - - - - - - - - E / A Konfiguration - - - - - - - - - - - - - - - - - - - - - - - - - -
Config Pinc.3 = Output
Ppm_signal Alias Portc.3
'============================ Pulslänge übertragen ===========================
Do
For I = 1 To 19 Step 2
Pulslaenge(i) = Us300
Pulslaenge(i + 1) = Us1200
Next I
Loop
'---------------------------- Timer 0 ----------------------------------------
Timer2_isr:
Ti = 1
Compare1a = Pulslaenge(ti)
Start Timer1
Set Ppm_signal
Return
'---------------------------- Timer 1 ----------------------------------------
Timer1_isr:
If Ti < 19 Then
Incr Ti
Compare1a = Pulslaenge(ti)
Toggle Ppm_signal
Else
Reset Ppm_signal
Stop Timer1
End If
Return
$regfile = "m32def.dat" : $crystal = 8000000
'---------------------------- Timer konfigurieren ----------------------------
Config Timer2 = Counter , Prescale = 1024 , Clear Timer = 1
On Oc2 Timer2_isr:
Ocr2 = 190
Config Timer1 = Counter , Prescale = 8 , Clear Timer = 1
On Oc1a Timer1_isr
'---------------------------- Interrupts einschalten -------------------------
Enable Oc1a
Enable Oc2
Start Timer0
Enable Interrupts
'---------------------------- Konstanten -------------------------------------
Const Us300 = 300 '63536
Const Us1200 = 1200 '55536
'---------------------------- Variablen RX -----------------------------------
Dim Pulslaenge(20) As Word
Dim Ti As Byte
Dim I As Byte
' - - - - - - - - - E / A Konfiguration - - - - - - - - - - - - - - - - - - - - - - - - - -
Config Pinc.3 = Output
Ppm_signal Alias Portc.3
'============================ Pulslänge übertragen ===========================
Do
For I = 1 To 19 Step 2
Pulslaenge(i) = Us300
Pulslaenge(i + 1) = Us1200
Next I
Loop
'---------------------------- Timer 0 ----------------------------------------
Timer2_isr:
Ti = 1
Compare1a = Pulslaenge(ti)
Start Timer1
Set Ppm_signal
Return
'---------------------------- Timer 1 ----------------------------------------
Timer1_isr:
If Ti < 19 Then
Incr Ti
Compare1a = Pulslaenge(ti)
Toggle Ppm_signal
Else
Reset Ppm_signal
Stop Timer1
End If
Return