
Zitat von
oiermann
Ich komme damit irgendwie nicht klar, probier auch schon die ganze Zeit herum, aber das hat weder Hand noch Fuss...
ja Bascom ist irgendwie eigen, ich blicke auch noch nicht volltändig durch, aber der Code funktioniert
Code:
$regfile = "2313def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Ddrb = &HFF
Ddrd = &H01
Config Rc5 = Pind.2
Portd.2 = 1
Enable Interrupts
Declare Sub Dimm_pwm
Dim Address As Byte , Command As Byte
Dim Oldaddress As Byte , Oldcommand As Byte
Oldaddress = 0
Oldcommand = 0
'$lib"lcd4busy.lib"
'define the used constants
'I used portA for testing
'Const _lcdport = Portb
'Const _lcdddr = Ddrb
'Const _lcdin = Pinb
'Const _lcd_e = 1
'Const _lcd_rw = 2
'Const _lcd_rs = 3
'this is like always, define the kind of LCD
Config Lcd = 20 * 4
'other options are 16 * 2 , 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Down , Prescale = 8
Dim A As Byte , Count As Long
Dim Strcount As String * 12
Portb.0 = 1
'and here some simple lcd code
Cursor Off Noblink
Cls
Locate 1 , 1 : Lcd "17tes " 'display this at the top line
Wait 1
Locate 2 , 1 : Lcd "im LOOP LED blinkt1"
A = Portd
Portd = 1
Waitms 500
Portd = 0
Waitms 500
'Loop
Locate 2 , 1 : Lcd "Waiting for RC5..."
Count = 0
Call Dimm_pwm
Do
Getrc5(address , Command)
If Address < 255 Then
Count = Count + 1
'If Count.0 = 0 Then
' Compare1a = 128
'Else
' Compare1a = 32
'End If
Strcount = Str(count)
A = 20 - Len(strcount)
Locate 1 , 8
Lcd " "
Locate 1 , A
Lcd Strcount
End If
Locate 3 , 1 : Lcd "Address=" ;
Locate 4 , 1 : Lcd "Command=" ;
If Address < 255 Then
If Address = 54 And Command = 7 Then
Toggle Portb.0
Waitms 500
Toggle Portb.0
End If
If Address = 7 And Command = 54 Then
Toggle Portb.0
Waitms 500
Toggle Portb.0
End If
Locate 3 , 9 : Lcd Address
If Command.7 = 1 Then
Portd = 1 : Command.7 = 0
Compare1a = 200
Else
Portd = 0
Compare1a = 8
End If
Locate 4 , 9 : Lcd Command
If Command <> Oldcommand Or Address <> Oldaddress Then
Oldcommand = Command
Oldaddress = Address
Locate 2 , 1 : Lcd " "
Locate 2 , 1 : Lcd "Old..."
Locate 2 , 7 : Lcd Oldaddress ; " ..."
Locate 2 , 11 : Lcd Oldcommand ; " ..."
Locate 2 , 15 : Lcd "Wait"
Count = 0
End If
Else
Locate 3 , 9 : Lcd " "
Locate 4 , 9 : Lcd " "
End If
Loop
End
Sub Dimm_pwm
Dim I As Byte , J As Byte
For I = 1 To 2
For J = 255 To 64 Step -10
Compare1a = J
Waitms 10
Next J
Wait 1
For J = 64 To 255 Step 10
Compare1a = J
Waitms 10
Next J
Wait 1
Next I
End Sub
Problem ist die Sprache als solches
folgendes wollte ich, gab Fehlermeldungen,
If ((Address = 54 And Command = 7) or (Address = 7 And Command = 54 ))Then
dieses funzt, ist aber doofer Stil
If Address = 54 And Command = 7 Then
Toggle Portb.0
Waitms 500
Toggle Portb.0
End If
If Address = 7 And Command = 54 Then
Toggle Portb.0
Waitms 500
Toggle Portb.0
End If
usw.
Lesezeichen