Hello,
I found a method to decode sony ir on the web and used it with Bascom AVR. It uses external interrupt and pulsin command to decode ir signal.
[code:1:edc0ac56af]
$regfile = "m8def.dat"
$crystal = 4000000
$hwstack = 128
$swstack = 256
$framesize = 256
$baud = 9600
Config Lcd = 16x2
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portb.1
Dim Ir_pulse(7) As Word
Dim I As Byte
Dim Dbyte As Byte
Dim Length As Word
Cls
Lcd "Bismillah"
Wait 2
Cls
Config Pind.2 = Input
Portd.2 = 1
On Int0 Int_0isr
Enable Int0
Enable Interrupts
Do
nop
Loop
Int_0isr:
'/////Check///////
'Disable Int0
' Pulsein Length , Pind , 2 , 0
' For I = 1 To 7
' Pulsein Ir_pulse(i) , Pind , 2 , 0
' Next I
' For I = 1 To 7
' Lcd "No.: " ; I ; ", " ; Ir_pulse(i)
' Wait 1
' Cls
' Next I
'Enable Int0
'/////Check///////
Disable Int0
Pulsein Length , Pind , 2 , 0
If Length > 200 Then
For I = 1 To 7
Pulsein Ir_pulse(i) , Pind , 2 , 0
Next I
Dbyte = &H7F
If Ir_pulse(1) < 100 Then
Dbyte.0 = 0
End If
If Ir_pulse(2) < 100 Then
Dbyte.1 = 0
End If
If Ir_pulse(3) < 100 Then
Dbyte.2 = 0
End If
If Ir_pulse(4) < 100 Then
Dbyte.3 = 0
End If
If Ir_pulse(5) < 100 Then
Dbyte.4 = 0
End If
If Ir_pulse(6) < 100 Then
Dbyte.5 = 0
End If
If Ir_pulse(7) < 100 Then
Dbyte.6 = 0
End If
Dbyte = Dbyte + 1
Lcd Dbyte
Wait 1
Cls
End If
Enable Int0
Return
[/code:1:edc0ac56af]
Please let me know if you find any mistake or way to improve it more.
Thanks.
↧