Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Micro RC5 remote on Tiny13/Tiny25

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 676

poland.gif
PostPosted: Thu Jan 02, 2020 2:44 am    Post subject: Micro RC5 remote on Tiny13/Tiny25 Reply with quote

Hello. This was made and tested for some polish forum.
Cause Bascom RC5SEND function needs 16bit Timer you cant use it in the Tiny13/Tiny25 because lack of such Timer.
I made some functions for coding, toggle bit and autorepeat and code is small about half of the Tiny13 flash Very Happy There is some spare bytes so one can add ADC keyboard or even simple switches.
This is short demo with only one function 12 for ON/OFF TV.

Code:
'***************************************************************************
'* 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 readed ori was 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
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5003
Location: Holland

blank.gif
PostPosted: Thu Jan 02, 2020 2:56 pm    Post subject: Reply with quote

Thank you EDC for this first shared code in 2020 Very Happy

And of course for taking the time to share this code.

_________________
Mark
Back to top
View user's profile Visit poster's website
Arek2014

Bascom Member



Joined: 30 Dec 2014
Posts: 20
Location: Kielce

poland.gif
PostPosted: Wed Feb 05, 2020 9:25 pm    Post subject: Reply with quote

Did receiver from link below will work ?

http://mirley.firlej.org/odbiornik_rc5
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum