Another one for F675 chip
Code:
'* Author : Craig S Gardner, Modified by Jonathan Peakall to *
'* : allow baud rate selection. *
CMCON = 7 ' Comparators OFF
ANSEL = 0 ' A/D OFF -- Port pins all digital
TRISIO = %010000 ' All I/O but GPIO3 = outputs
GPIO = %000000 ' All 0 on boot
sBaud var byte
IRpulse_length var word(13)
xx var Byte
Command Var Byte
Device Var Byte
input gpio.3
'clear
pause 500
sbaud = 2
if gpio.3 = 1 then
sBaud = 2
endif
if gpio.3 = 0 then
sBaud = 0
endif
Getstartbits:
PuLSIN GPIO.1,0,IRpulse_length(0)
if IRpulse_length(0) < 200 then
goto getstartbits
Endif
for xx=1 to 12
pulsin GPIO.1,0,IRpulse_length(xx)
next xx
displaybits:
if IRpulse_length(1) < 100 then
Command.bit0 = 0
Else
Command.bit0 = 1
endif
if IRpulse_length(2) < 100 then
Command.bit1 = 0
Else
Command.bit1 = 1
endif
if IRpulse_length(3) < 100 then
Command.bit2 = 0
Else
Command.bit2 = 1
endif
if IRpulse_length(4) < 100 then
Command.bit3 = 0
Else
Command.bit3 = 1
endif
if IRpulse_length(5) < 100 then
Command.bit4 = 0
Else
Command.bit4 = 1
endif
if IRpulse_length(6) < 100 then
Command.bit5 = 0
Else
Command.bit5 = 1
endif
if IRpulse_length(7) < 100 then
Command.bit6 = 0
Else
Command.bit6 = 1
endif
Command.bit7 = 0
Command = Command + 1
If Command = 10 then
Command = 0
Endif
if IRpulse_length(8) < 100 then
Device.bit0 = 0
Else
Device.bit0 = 1
endif
if IRpulse_length(9) < 100 then
Device.bit1 = 0
Else
Device.bit1 = 1
endif
if IRpulse_length(10) < 100 then
Device.bit2 = 0
Else
Device.bit2 = 1
endif
if IRpulse_length(11) < 100 then
Device.bit3 = 0
Else
Device.bit3 = 1
endif
'Device.bit1 = 0
SEROUT GPIO.0,sbaud,[Device,Command]
pause 100
goto Getstartbits
Ioannis
Bookmarks