View previous topic :: View next topic |
Author |
Message |
kan042
Joined: 18 May 2009 Posts: 5
|
Posted: Thu Apr 13, 2017 12:31 pm Post subject: RC5 and Attiny45 Problem |
|
|
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 |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
kan042
Joined: 18 May 2009 Posts: 5
|
Posted: Sat Apr 15, 2017 6:34 pm Post subject: |
|
|
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 |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Sun Apr 16, 2017 12:19 am Post subject: |
|
|
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 |
|
|
kan042
Joined: 18 May 2009 Posts: 5
|
Posted: Sun Apr 16, 2017 4:27 pm Post subject: |
|
|
Many thanks to everyone.
Now, everything is working properly.
@Evert I'll remember this lesson forever, thank you once more. |
|
Back to top |
|
|
|