Napisałem takie Demo i zostało tam pół procka flash i kilka bajtów z tych nędznych 64 w Tiny13 więc można sobie dopisać jakieś dodatkowe komendy albo klawiaturę na ADC...
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- '***************************************************************************
- '* 8PIN uC Tiny13/Tiny25-Tiny85 NO 16BIT Timer RC5SEND DEMO by BARTek EDC *
- '***************************************************************************
- $regfile = "attiny13a.dat"
- $crystal = 9600000
- $hwstack = 6
- $swstack = 0
- $framesize = 12
- Osccal = 30 'tune internal oscillator (My ori 20)
- Const _delay = 880 'x useconds (ori 889)
- Config Portb = &B00001 : Portb = &B11110 'OC0A on PORTB.0 but overrided by Timer0
- Switch Alias Pinb.3
- Config Timer0 = Timer , Prescale = 1 , Compare_a = Toggle , Clear_timer = 1
- 'Compare0 = 132 '36kHz @9,6MHz Tiny13
- Compare0 = 125 '38kHz @9,6MHz Tiny13
- 'Compare0 = 110 ' 36kHz @8MHz TinyX5
- Tccr0a.com0a0 = 0 'disconnect 36kHz carrier from Timer0 but if this is REM or 1 then you can tune 36-38 kHz carrier
- Dim Mframe As Word , Address As Byte , Command As Byte
- Dim Togg As Byte , Snd As Byte , Temp As Word
- Address = 0 : Command = 12 'for test ON/OFF TV
- Do
- If Switch = 0 Then
- Gosub Make_frame
- Gosub Send_frame
- While Switch = 0 'repeat till switch release
- Waitms 85
- Gosub Send_frame
- Wend
- End If
- Loop
- Make_frame:
- Mframe = Address
- Shift Mframe , Left , 6
- Mframe = Mframe + Command
- If Togg = 0 Then
- Togg = 1
- Mframe = Mframe Or &B0011_1000_0000_0000 'set toggle
- Else
- Togg = 0
- Mframe = Mframe Or &B0011_0000_0000_0000 'reset toggle
- End If
- Return
- Send_frame:
- Snd = 14
- Temp = Mframe
- Shift Temp , Left , 2
- Do
- If Temp.15 = 0 Then
- Gosub Bit0 'send bit 0
- Else
- Gosub Bit1 'send bit 1
- End If
- Shift Temp , Left , 1 'move over frame
- Decr Snd 'till 14 bit is send
- Loop Until Snd = 0
- Return
- Bit0:
- Tccr0a.com0a0 = 1 'enable carrier by attach it ito 36kHz Timer0
- Waitus _delay
- Tccr0a.com0a0 = 0 'disable carrier
- Waitus _delay
- Return
- Bit1:
- Waitus _delay
- Tccr0a.com0a0 = 1
- Waitus _delay
- Tccr0a.com0a0 = 0
- Return