CONFIG RC5/de

Aus MCS Wiki AVR
Wechseln zu: Navigation, Suche

Inhaltsverzeichnis

= (**COPIED FROM ENGLISH PAGE**) === Action

Overrides the RC5 pin assignment from the Option Compiler Settings.

 

 

Syntax

CONFIG RC5 = pin [,TIMER=2] [,WAIT=value] [,MODE=BACKGROUND]

 

 

Remarks

Pin

The port pin to which the RC5 receiver is connected.

TIMER

Must be 2. The micro must have a timer2 when you want to use this option. This additional parameter will cause that TIMER2 will be used instead of the default TIMER0.

WAIT

The default value is 100. Each unit is ca. 64 us. This gives a time out of 6.4 ms.  Since a start bit is 3.5 ms, you can reduce the value to 56. When you make it lower, it will not work.

When you want the old behavior you need to specify a value of 2000 which is ca. 131 ms.

MODE

The only possible value is BACKGROUND.

The MODE parameter is optional. When used, an alternative library will be used to decode the RC5 signals on the background. This means that GETRC5 will not wait for a signal but that a bit will be set to indicate that a valid RC5 signal is received. This is bit : _rc5_bits.4

The variable _rc5_bits is automatically created when you use the MODE=BACKGROUND. This option is not available in the DEMO.

The background mode will use a 16 bit timer in capture mode. It also means that you need to connect the IR-transmitter output pin to the ICP capture pin of the timer.

When using the background mode, you must specify a 16 bit timer.

 

 

When you use different pins in different projects, you can use this statement to override the Options Compiler setting for the RC5 pin. This way you will remember which pin you used because it is in your code and you do not have to change the settings from the options. In BASCOM-AVR the settings are also stored in the project.CFG file. We recommend to use the CONFIG commands.

 

 

See also

GETRC5

 

 

Example


'-------------------------------------------------------------------
' RC5.BAS
' (c) 1999-2012 MCS Electronics
' based on Atmel AVR410 application note
'-------------------------------------------------------------------
$RegFile = "m88def.dat"
 
$Baud = 19200
$Crystal = 16000000
 
'This example shows how to decode RC5 remote control signals
'with a SFH506-35 IR receiver.
 
'Connect to input to PIND.2 for this example
'The GETRC5 function uses TIMER0 and the TIMER0 interrupt.
'The TIMER0 settings are restored however so only the interrupt can not
'be used anymore for other tasks
 
 
'tell the compiler which pin we want to use for the receiver input
 
Config Rc5 = PIND.2 , Wait = 2000
Config Timer1 = Timer , Prescale = 1
 
'the interrupt routine is inserted automatic but we need to make it occur
'so enable the interrupts
Enable Interrupts
 
'reserve space for variables
Dim Address As Byte , Command As Byte
Print "Waiting for RC5..."
 
Do
'now check if a key on the remote is pressed
'Note that at startup all pins are set for INPUT
'so we dont set the direction here
'If the pins is used for other input just unremark the next line
'Config Pind.2 = Input
'Print Timer1 disable this line to see the different with the various WAIT constants
GetRC5(Address , Command)
 
'we check for the TV address and that is 0
If Address = 0 Then
 'clear the toggle bit
 'the toggle bit toggles on each new received command
 'toggle bit is bit 7. Extended RC5 bit is in bit 6
 Command = Command And &B01111111
 Print Address ; " " ; Command
End If
Loop
End

Example MODE=background


'----------------------------------------------------------------------------------------------------------
' (c) 1995-2012
' RC5-background.bas
' this sample receives RC5 on the background. it will not block your code like getrc5
' it requires a 16 bit timer with input capture. you can not use the timer yourself.
' some processors have multiple 16 bit timers.
'----------------------------------------------------------------------------------------------------------
$regfile = "m88def.dat"
$crystal = 8000000
$baud = 19200
$hwstack = 64
$swstack = 64
$framesize = 64
 
Config Rc5 = Pinb.0 , Timer = 1 , Mode = Background
' ^--- background interrupt mode
' ^--- this must be a 16 bit timer
' ^---- this is the timer input capture pin
 
Enable Interrupts ' you must enable interrupts since input capture and overflow are used
 
 
Print "RC5 demo"
 
Do
If _rc5_bits.4 = 1 Then ' if there is RC5 code received
 _rc5_bits.4 = 0 ' you MUST reset this flag in order to receive a new rc5 command
 
 Print "Address: " ; Rc5_address ' Address
 Print "Command: " ; Rc5_command ' Command
End If
Loop

Languages   English Deutsch  
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
In anderen Sprachen
Sprache