Hi David,
thank you for your hinds.
I don’t know wether there is a way to call external libraries from BASCOM-AVR, but i believe no.
After a friend had a look to the C-code, he told me what to do.
I only had to learn how to handle the Timer2 with PWM with BASCOM.
After a search in the www , an Update to BASCOM-AVR Ver.2.0.2.1 and study the chematics i found
a easy way.
The sample works fine and shows how to use BASCOM on the Orangutan Controller.
The only thing ,i don’t know until yet, is: which port drives the Servo-Multiplexer?
Here the Bascom-Code which i have tested.
Regards Uwe
-----------------------------------------------------------------------------------------------
' BASCOM-AVR Ver.2.0.2.1
' Uwe Fricke
' [uw.fricke@web.de](mailto:uw.fricke@web.de)
' -----------------------------------
'LCD-Display & Hardware PWM mit Timer2
' mit Pololu Orangutan SVP
$regfile = "m1284Pdef.dat"
$crystal = 20000000
Dim N As Integer
Dim Anzeige2 As String * 16
'------------------------------------------------------------------------------------------------
'Rs = PortB.0
'RW = PortB.1 R/W option wird hier nicht benötigt
' E = PortB.2
'Db0, Db1, Db2 und Db3 sind auf Masse ; auf Masse
'Db4 = PortC.2
'Db5 = PortC.3
'Db6 = PortC.4
'Db7 = PortC.5
'----------------------------------------------------------
' LCD-Anzeige vorbereiten Daten- und Steueranschlüße definieren
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.2 , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcdbus = 4
'----------------------------------------------------------
'---------Zusätzlich neue Zeichen definieren---define new own characters ----------
' Deflcdchar 1 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 ' |
' Deflcdchar 2 , 24 , 24 , 24 , 24 , 24 , 24 , 24 , 24 ' ||
' Deflcdchar 3 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 ' |||
' Deflcdchar 4 , 30 , 30 , 30 , 30 , 30 , 30 , 30 , 30 ' ||||
' Deflcdchar 5 , 31 , 31 , 31 , 31 , 31 , 31 , 31 , 31 ' |||||
Deflcdchar 1 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 31 '
Deflcdchar 2 , 32 , 32 , 32 , 32 , 32 , 32 , 31 , 31 '
Deflcdchar 3 , 32 , 32 , 32 , 32 , 32 , 31 , 31 , 31 '
Deflcdchar 4 , 32 , 32 , 32 , 32 , 31 , 31 , 31 , 31 '
Deflcdchar 5 , 32 , 32 , 32 , 31 , 31 , 31 , 31 , 31 '
Deflcdchar 6 , 32 , 32 , 31 , 31 , 31 , 31 , 31 , 31 '
Deflcdchar 7 , 32 , 31 , 31 , 31 , 31 , 31 , 31 , 31 '
'----------------- Now use an internal routine ------------
_temp1 = 1 'value into ACC
!rCall _write_lcd 'put it on LCD
Cursor Off , Noblink
'------------------------------------------------------------------------------------------------
Config Portc.6 = Output
Config Portc.7 = Output
Config Portd.6 = Output
Config Portd.7 = Output
'Config Timer2 = Pwm , Pwm = On , Compare A = Clear , Prescale = 8
Config Timer2 = Pwm , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up , Prescale = 8
Ocr2a = 255 ' Pwm-Output OC2A = 0 Minimum / 255 => Maximum
Ocr2b = 255 ' Pwm-Output OC2B = 0 Minimum / 255 => Maximum
Portc.6 = 0 ' rotating direction Dir2
Portc.7 = 1 ' rotating direction Dir1
Enable Timer2
'LCD-Display ------------------------------------------------------------------------------------
Locate 1 , 1
Lcd " BASCOM-Test"
Locate 2 , 1
Lcd Chr(1) ; Chr(1) ; Chr(2) ; Chr(3) ; Chr(4) ; Chr(5) ; Chr(6) ; Chr(7) ; Chr(7) ; Chr(6) ; Chr(5) ; Chr(4) ; Chr(3) ; Chr(2) ; Chr(1) ; Chr(1)
Wait 2
Locate 2 , 1
Lcd "LCD / PWM-Timer2"
Wait 2
Locate 2 , 1
Lcd " AVR ATmega 1248P"
Wait 2
Locate 2 , 1
Lcd " "
Wait 1
Locate 2 , 1
Lcd " OCR2A : "
' PWM -------------------------------------------------------------------------------------------
Do
Portc.7 = 0 ' Drehrichtung festlegen / set direction
'------------------------------------------------------------------------------------------------
For N = 255 To 0 Step -1 ' Drehzahl von 0 > Max erhöhen
' inc. rotatation speed
Ocr2a = N
Waitms 50
Locate 2 , 10
Anzeige2 = Str(ocr2a)
Anzeige2 = Format(anzeige2 , "000")
Locate 2 , 10
Lcd Anzeige2
Next N
'------------------------------------------------------------------------------------------------
Portc.7 = 1 ' Drehrichtung ändern / change direction
Wait 2
'------------------------------------------------------------------------------------------------
For N = 0 To 255 ' Drehzahl von Max > 0 senken
' dec.. rotatation speed
Ocr2a = N
Waitms 50
Anzeige2 = Str(ocr2a)
Anzeige2 = Format(anzeige2 , "000")
Locate 2 , 10
Lcd Anzeige2
Next N
'------------------------------------------------------------------------------------------------
Wait 2
Ocr2b = 0 ' Pwm-Output OC2B = MAX / LED on
For N = 1 To 20 ' Blinking with D5 and D6
Portc.6 = 0
Waitms 250
Portc.6 = 1 ' Drehrichtung ändern / change direction OC2B
Waitms 250
Next N
Ocr2b = 255 ' Pwm-Output OC2B = Min / LED off
Loop
'------------------------------------------------------------------------------------------------
End