Also ich hab bei Bascom 2 Code gefunden, müsstest du dir allerdings selber erklären. Ich denke Trabukh meinte pulsin1.bas:
Code:
Declare Function Lopulse() As Byte
Dim Value As Byte
Const Inputpin = $10 , 0 ' Inputpin Alias Pind.0
Config Portb = Output
Portb = &HFF
Config Timer0 = Timer , Prescale = 1
On Timer0 Overflow_isr Nosave
Enable Timer0
Enable Interrupts
Do
Value = Lopulse()
Portb = Value
Loop
End
Function Lopulse() As Byte
$asm
Hilo:
Sbic Inputpin ' wait for Hi-Lo on inputpin
Rjmp Hilo
$end Asm
Tcnt0 = 0 ' reset Timer0
Start Timer0
$asm
Lohi:
Sbis Inputpin ' wait for Hi-Lo on inputpin
Rjmp Lohi
$end Asm
Stop Timer0 ' stop Timer0 after 26 cycles minimum
Lopulse = Tcnt0
End Sub
' overflow isr stops timer0 and set tcnt0 to zero
Overflow_isr:
!push R24
Stop Timer0
Tcnt0 = 0
!pop R24
Return
bzw. Pulsein2.bas:
Code:
Declare Function Lopulse() As Word
Dim Value As Word
Dim Time As Word
Inputpin Alias Pind.0
Config Portb = Output
Portb = &HFF
Do
Value = Lopulse()
Portb = Low(value)
Loop
End
Function Lopulse() As Word
' Local Time As Word
While Inputpin <> 0 : Wend
Time = 0 ' reset Timer0
While Inputpin = 0
Incr Time
Wend
Lopulse = Time
End Sub
MFG Moritz
Lesezeichen