'////////////////////////////////////////////////////////// '/// FastAVR Basic Compiler for AVR by MICRODESIGN /// '/// RC5out.bas STK-200, STK-500 www.FastAVR.com /// '/// output is on OC pin, at 2313 is on PORTB.3 /// '/// output is active HIGH /// '////////////////////////////////////////////////////////// $Device= 2313 ' used device $Stack = 32 ' stack size $Clock = 7.3728 ' used clock in MHz $Timer1=Timer, Prescale=1, CompareA=Toggle, Clear $Source= On Declare Sub RC5out(adr As Byte, command As Byte) Declare Sub BitLow() Declare Sub BitHigh() Dim ToggleBit As Bit Dim Adr As Byte, Command As Byte Const Delay=89 ' 890us Set DDRB.3 ' here is output Compare1A=101 ' n=(Q/f-2)/2 Start Timer1 Adr=0 ' TV set family address Command=5 ' for test only Do RC5out(Adr,Command) WaitMs 90 'ToggleBit=Not ToggleBit Loop '////////////////////////////////////////////////////////// Sub RC5out(adr As Byte, command As Byte) ' adr is RC5 family address ' command is RC5 commant to send ' toggle bit toggles when user releases key Local i As Byte BitHigh() BitHigh() If ToggleBit Then BitHigh() Else BitLow() End If For i=0 To 4 If adr.4 Then BitHigh() Else BitLow() End If Shift(Left,1,adr) Next For i=0 To 5 If command.5 Then BitHigh() Else BitLow() End If Shift(Left,1,command) Next $Timer1=Timer, CompareA=Reset End Sub '////////////////////////////////////////////////////////// Sub BitLow() ' makes LOW manchester bit $Timer1=Timer, CompareA=Toggle ' WaitUs Delay $Timer1=Timer, CompareA=Reset WaitUs Delay End Sub '////////////////////////////////////////////////////////// Sub BitHigh() ' makes HI manchester bit WaitUs Delay $Timer1=Timer, CompareA=Toggle WaitUs Delay $Timer1=Timer, CompareA=Reset End Sub