Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

RC5 and Attiny45 Problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions
View previous topic :: View next topic  
Author Message
kan042

Bascom Member



Joined: 18 May 2009
Posts: 5

bosnia_herzegovina.gif
PostPosted: Thu Apr 13, 2017 12:31 pm    Post subject: RC5 and Attiny45 Problem Reply with quote

I'm trying to make a remote control with RC5. IR works but I get weird results. Initially 'Else' and '35' are working correctly but as soon as I choose on 16 or 17 all go crazy. The program is totally simple, where I'm wrong?

Code:

$regfile = "attiny45.dat"
$crystal = 8000000
$hwstack = 20
$swstack = 10
$framesize = 40

$lib "mcsbyte.lbx"

Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Config Portb.3 = Input
Config Portb.4 = Input

Config Rc5 = Pinb.3 , Wait = 2000

Dim Address As Byte , Command As Byte , Command_old As Byte

Clk Alias Pinb.2
D Alias Pinb.1
Rst Alias Pinb.0
Clk = 0
Rst = 0

Enable Interrupts

Do
   Getrc5(address , Command)
      If Address = 8 Then
        Command = Command And &B01111111
          Gosub Readrc5
      End If
Loop

Readrc5:
Select Case Command
   Case 16                                                  '1. LED
      Clk = 0
      Rst = 1
      Waitms 100
   Case 17                                                  '2. LED
      Clk = 1
      Rst = 0
      Waitms 100
   Case 35                                                  'NONE
      Clk = 0
      Rst = 0
      Waitms 100
   Case Else                                                '1. & 2. LED
      Clk = 1
      Rst = 1
      Waitms 100
   End Select
Return
 


Thank You in advance

(BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.8 )
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Sat Apr 15, 2017 11:55 am    Post subject: Reply with quote

Remove the $lib "mcsbyte.lbx" line
and increase your Swstack.

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
kan042

Bascom Member



Joined: 18 May 2009
Posts: 5

bosnia_herzegovina.gif
PostPosted: Sat Apr 15, 2017 6:34 pm    Post subject: Reply with quote

Thank You very much.
I tried a lot of combinations. I changed all stacks, changed and removed out the value "WAIT" in the statement 'config RC5', removed mcsbyte.lbx, but not working properly.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Apr 16, 2017 12:14 am    Post subject: Reply with quote

Hello kano42
I did some work with remote controls
I wanted a universal receiver
I documented the work here
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=10989&highlight=infra+red
Then a universal one here
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=11304&highlight=universal
This may help you
Regards Paul
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2156

netherlands.gif
PostPosted: Sun Apr 16, 2017 12:19 am    Post subject: Reply with quote

And this should be changed
Code:

Clk Alias Pinb.2
D Alias Pinb.1
Rst Alias Pinb.0
 

in
Code:

Clk Alias Portb.2
D Alias Portb.1
Rst Alias Portb.0
 


Remember that pin is IN and port is OUT

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
kan042

Bascom Member



Joined: 18 May 2009
Posts: 5

bosnia_herzegovina.gif
PostPosted: Sun Apr 16, 2017 4:27 pm    Post subject: Reply with quote

Many thanks to everyone.
Now, everything is working properly.
@Evert I'll remember this lesson forever, thank you once more.
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Unsupported versions 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