'****************************************************************************** '****************************************************************************** ' ' Program Title: rc5.bas ' Written By: Michael J. Cook - KD5DHU ' Notice: Copyright (c) 2002 Michael J. Cook, All Rights Reserved ' Start Date: 06/29/2003 ' Last Update: 06/29/2003 ' Compiler: BASCOM-AVR v1.11.7.4 ' Processor: Atmel AT90S2313/10PC ' Revision ID: u - un-released: in-house testing ' r - Released: commercial version ' b - beta release: selected group for testing ' a - alpha release: emergency release, not ' completely tested. ' ' Current Version: v1.0.0u ' ' Program Function: This example shows how to decode RC5 remote control ' signals with a TSOP1736 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. ' ' Project Status: Development stage, still evaluating hardware. ' ' ' Program Development History: ' ' Date: Version: Notes: ' ' 06/29/2003 - (v1.0.0u) - Started program template. ' '***** Hardware is connected as follows: ************************************** ' ' ------ ------ ' | | ' ISP Reset --| 1 20 |-- VCC +5 VDC ' | | ' MAX232-7 (RXD) PD0 --| 2 19 |-- PD7 (SCK) ISP ' | | ' MAX232-8 (TXD) PD1 --| 3 18 |-- PB6 (MISO) ISP ' | | ' CRYSTAL XTAL2 --| 4 17 |-- PB5 (MOSI) ISP ' | | ' CRYSTAL XTAL1 --| 5 16 |-- PB4 ' | | ' TSOP1736-3 (INT0) PD2 --| 6 15 |-- PB3 (OC1) ' | | ' LED (INT1) PD3 --| 7 14 |-- PB2 ' | | ' (T0) PD4 --| 8 13 |-- PB1 (AIN1) ' | | ' (T1) PD5 --| 9 12 |-- PB0 (AIN0) ' | | ' ISP/GROUND GND --| 10 11 |-- PD6 (ICP) ' | | ' ------------- ' ' ' Item AT90S2313/10PC PC Port '------------------------------------------------------------------------------ ' ' AVR Micro Controller: ' -------------------- ' ' Note: For the ISP to work correctly a series 330 ohm resistor was placed ' between D0, D2, and D3 and the pin to the parallel port. ' ' ISP MOSI Pin 17 Parallel DB25 PIN 2, D0 ' ISP MISO Pin 18 Parallel DB25 PIN 11, BUSY ' ISP CLOCK Pin 19 Parallel DB25 PIN 5, D3 ' ISP RESET Pin 1 Parallel DB25 PIN 4, D2 ' ISP GROUND Pin 10 Parallel DB25 PIN 18-25, GROUND ' ' +5VDC Pin 20 ' Ground Pin 10 ' ' Crystal w/cap to GND Pin 4 ' Crystal w/cap to GND Pin 5 ' ' '***** Compiler Setup: ******************************************************** ' 'Use byte library for smaller code $Lib "mcsbyte.lbx" $REGFILE = "2313DEF.DAT" $Baud = 19200 $Crystal = 7372800 'Tell the compiler which pin we want to use for the receiver input Config Rc5 = Pind.2 'The interrupt routine is inserted automatic but we need to make it occur so 'enable the 'interrupts Enable Interrupts Wait 1 'Reserve space for variables Dim Address As Byte DIM Command As Byte Print "RC5 IR Receiver - Ready" Do 'Now check if a key on the remote is pressed. Note that at startup all pins are 'set for INPUT so we don't set the direction here. If the pins are used for 'other input just un-'remark 'the next line. Config Pind.2 = Input Config Pind.3 = Output Getrc5(Address , Command) 'Check for the address to see if it's different from 255, 255 means no code 'received. If Address <> 255 Then Set PORTD.3 '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 "+IR-REMOTE," ; Address ; Command WAITMS 250 Reset PORTD.3 End If Loop