eine einfache bewegung mit dem rp6 und ir-rc5 :vorwärts,rückwärts, links drehen , rechts drehen und stop.

es ist verbesserungswürdig. aber zum ersten testen des rp6 mit Bascom reicht es erstmal.

dieses muss in der m32def.dat ausgewechselt werden, weil ich die neuen bezeichnungen von atmel nehme und die auch bei winavr-c genommen werden:

;TCCR1A
COM1A1 =7
COM1A0 =6
COM1B1 =5
COM1B0 =4
FOC1A =3
FOC1B =2
PWM11 =1
WGM11 =1 ; neu
PWM10 =0
WGM10 =0 ; neu

;TCCR1B
ICNC1 =7
ICES1 =6
CTC11 =4
WGM13 =4 ; neu
CTC10 =3
WGM12 =3 ; neu
CS12 =2
CS11 =1
CS10 =0

Code:
$regfile = "M32def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 32
$framesize = 64
$baud = 38400

Declare Sub Rp6_vorwaerts()
Declare Sub Rp6_rueckwaerts()
Declare Sub Rp6_stop()
Declare Sub Rp6_links()
Declare Sub Rp6_rechts()

Dim Tccr1a_set As Byte
Dim Tccr1b_set As Byte
Dim Wert As Byte
Dim Zaehler As Word
Dim Zaehler1 As Word
Dim Test As Byte

Dim Address As Byte , Command As Byte

Config Rc5 = Pinb.2

Config Pinc.2 = Output
Config Pinc.3 = Output
Config Pinb.4 = Output

On Int0 Int0_int
On Int1 Int1_int
On Int2 Int2_int

Enable Interrupts

Config Int0 = Falling
Config Int1 = Falling

Enable Int0
Enable Int1
Enable Int2

Tccr1a_set = 0
Tccr1b_set = 0

Reset Tccr1a_set .wgm10
Set Tccr1a_set .wgm11
Set Tccr1a_set .com1a1
Set Tccr1a_set .com1b1
Tccr1a = Tccr1a Or Tccr1a_set

Reset Tccr1b_set .wgm12
Set Tccr1b_set .wgm13
Set Tccr1b_set .cs10
Tccr1b = Tccr1b Or Tccr1b_set

Icr1h = 0
Icr1l = 210

Set Portb.4

Wert = 0

Wait 1

Do

Waitms 500


Loop

Reset Portb.4

End

Int0_int:
   Disable Int0
   Enable Interrupts
   Zaehler = Zaehler + 1
   Enable Int0
Return

Int1_int:
   Disable Int1
   Enable Interrupts
   Zaehler1 = Zaehler1 + 1
   Enable Int1
Return

Int2_int:
   Disable Int2
   Enable Interrupts
   Getrc5(address , Command)
   If Command = 1 Then
      Call Rp6_vorwaerts()
   End If
   If Command = 2 Then
      Call Rp6_rueckwaerts()
   End If
   If Command = 3 Then
      Call Rp6_links()
   End If
   If Command = 4 Then
      Call Rp6_rechts()
   End If
   If Command = 0 Then
      Call Rp6_stop()
   End If
   Enable Int2
Return

Sub Rp6_vorwaerts()
      Call Rp6_stop()

      Reset Portc.2
      Reset Portc.3

      For Wert = 0 To 100
         Waitms 20
         Pwm1a = Wert - 3
         Pwm1b = Wert
      Next
End Sub

Sub Rp6_rueckwaerts()
      Call Rp6_stop()

      Set Portc.2
      Set Portc.3

      For Wert = 0 To 100
         Waitms 20
         Pwm1a = Wert - 3
         Pwm1b = Wert
      Next
End Sub

Sub Rp6_links()
      Call Rp6_stop()

      Set Portc.2
      Reset Portc.3

      For Wert = 0 To 60
         Waitms 20
         Pwm1a = Wert
         Pwm1b = Wert
      Next
End Sub

Sub Rp6_rechts()
      Call Rp6_stop()

      Reset Portc.2
      Set Portc.3

      For Wert = 0 To 60
         Waitms 20
         Pwm1a = Wert
         Pwm1b = Wert
      Next
End Sub

Sub Rp6_stop()

    For Test = Wert To 0 Step -1
        Pwm1b = Test
        Pwm1a = Test
        Waitms 10
    Next

    Wert = 0

End Sub