8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver



Similar documents
8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

AT89C5131A Starter Kit... Software User Guide

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

General Porting Considerations. Memory EEPROM XRAM

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

USB Test Environment ATUSBTEST- SS7400. Summary

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

2-wire Serial EEPROM AT24C1024. Advance Information

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Building A RISC Microcontroller in an FPGA

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

Two-wire Serial EEPROM AT24C1024 (1)

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

STK 500, AVRISP, AVRISP

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

AVR318: Dallas 1-Wire master. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

2-wire Serial EEPROM AT24C512

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR068: STK500 Communication Protocol. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

8-bit Microcontroller. Application Note. AVR313: Interfacing the PC AT Keyboard

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

All-band AM/FM Receiver and Audio Amplifier IC U2510B

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

AVR064: A Temperature Monitoring System with LCD Output. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR441: Intelligent BLDC Fan Controller with Temperature Sensor and Serial Interface. 8-bit Microcontrollers. Application Note.

Voltage boost and buck circuits using Atmel AVR Tiny13V for driving a white LED.

AT91 ARM Thumb Microcontrollers. Application Note. GNU-Based Software Development on AT91SAM Microcontrollers. 1. Introduction. 2.

Application Note. 8-bit Microcontrollers. AVR435: BLDC/BLAC Motor Control Using a Sinus Modulated PWM Algorithm. 1. Features. 2.

Manchester Coding Basics. Application Note. Manchester Coding Basics. 1. Modulation

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

Application Note Microcontrollers. Guidelines to Keep ADC Resolution within Specification. Introduction. ADC Resolution

256K (32K x 8) OTP EPROM AT27C256R 256K EPROM. Features. Description. Pin Configurations

8-bit. Application Note. Microcontrollers. AVR273: USB Mass Storage Implementation. Features. 1. Introduction

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Basic Interrupts and I/O

JTAG ICE.... User Guide

AVR447: Sinusoidal driving of three-phase permanent magnet motor using ATmega48/88/ bit Microcontrollers. Application Note.

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

80C51 MCU s. Application Note. Analyzing the Behavior of an Oscillator and Ensuring Good Start-up. Oscillator Fundamentals

Transcription:

AVR410: RC5 IR Remote Control Receiver Features Low-cost Compact Design, Only One External Component Requires Only One Controller Pin, Any AVR Device Can be Used Size-efficient Code Introduction Most audio and video systems are equipped with an infrared remote control. This application note describes a receiver for the frequently used Philips/Sony RC5 coding scheme. 8-bit Microcontroller Application Note Figure 1. RC5 Receiver DATA The RC5 code is a 14-bit word bi-phase coded signal (See Figure 2). The two first bits are start bits, always having the value one. The next bit is a control bit or toggle bit, which is inverted every time a button is pressed on the remote control transmitter. Five system bits hold the system address so that only the right system responds to the code. Usually, TV sets have the system address 0, VCRs the address 5 and so on. The command sequence is six bits long, allowing up to 64 different commands per address. The bits are transmitted in bi-phase code (also known as Manchester code) as shown in Figure 3. An example where the command 0x35 is sent to system 5 is shown in Figure 4. Rev. 1

Figure 2. RC5 Frame Format Figure 3. Bi-phase Coding Figure 4. Example of Transmission Timing The Software The Detect Subroutine The bit length is approximately 1.8 ms. The code is repeated every 114 ms. To improve noise rejection, the pulses are modulated at 36 khz. The easiest way to receive these pulses is to use an integrated IR-receiver/demodulator like the Siemens SFH 506-36. This is a 3-pin device that receives the infra-red burst and gives out the demodulated bit stream at the output pin. Note that the data is inverted compared to the transmitted data (i.e., the data is idle high). The assembly code found in AVR410.ASM contains the RC5 decode routine. In addition, it contains an example program which initializes the resources, decodes the RC5 data and outputs the received command on port B. When the detect subroutine is called, it first waits for the data line to be idle high for more than 3.5 ms. Then, a start bit can be detected. The length of the low part of the first start bit is measured. If no start bit is detected within 131 ms, or if the low pulse is longer than 1.1 ms, the routine returns indicating no command received. Figure 5. Synchronizing and Sampling of the Data The measurement of the start bit is used to calculate two reference times, ref1 and ref2, which are used when sampling the data line. The program uses the edge in the middle of every bit to synchronize the timing. 3/4 bit length after this edge, the line is sampled. This is in the middle of the first half of the next bit (see Figure 5). The state is stored and the routine waits for the middle edge. Then, the timer is synchronized again and everything is repeated for the following bits. If the synchronizing edge is not detected within 5/4 bit times from the previous synchronizing edge, this is detected as a fault and the routine terminates. When all the bits are received, the command and system address are stored in the command and system registers. The control bit is stored in bit 6 of command. 2 AVR410

AVR410 Table 1. Decode Subroutine Performance Figures Parameter Code Size Execution Cycles Value 72 words Register Usage Low Registers Used: 3 High Registers Used: 6 Global Registers: 6 Pointers Used: None Table 2. Detect Register Usage Register Internal Output R1 R2 R3 R16 R17 R18 R19 R20 R21 inttemp Used by TIM0_OVF ref1 Holds Timing Information ref2 Holds Timing Information temp Temporary Register timerl Timing Register timerh Timing Register bitcnt Counts the Bits Received system The System Address command The Received Command Timer/Counter0 Overflow Interrupt Handler The function of the timer interrupt is to generate a clock base for the timing required. The routine increments the timerl Register every 64 µs, and the timerh every 16,384 ms. Table 3. TIM0_OVF Interrupt Handler Performance Figures Parameter Code Size Execution Cycles Value 7 words 6 + reti Register Usage Low Registers Used: 2 High Registers Used: 2 Global Registers: 0 Pointers Used: None Table 4. TIM0_OVF Register Usage Register Internal Output R0 S Temporary Storage of Sreg R1 inttemp Used by TIM0_OVF R17 timerl Incremented every 64 µs R18 timerh Incremented every 16,384 ms 3

Example Program The example program initializes the ports, sets up the timer and enables interrupts. Then, the program enters an eternal loop, calling the detect routine. If the system address is correct, the command is output on port B. Table 5. Overall Performance Figures Parameter Code Size Value Register Usage Low Registers: 4 High Registers: 6 Pointers: None Interrupt Usage Peripheral Usage 79 words detect and TIM0_OVF 96 words Complete Application Note Timer/Counter 0 Interrupt Timer/Counter Port D, pin 2 Port B (example program only) 4 AVR410

AVR410 ************************************************************************** A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y Number : AVR410 File Name :"rc5.asm" Title :RC5 IR Remote Control Decoder Date :97.08.15 Version :1.0 Support telephone :+47 72 88 43 88 (ATMEL Norway) Support fax :+47 72 88 43 99 (ATMEL Norway) Target MCU :AT90S1200 DESCRIPTION This Application note describes how to decode the frequently used RC5 IR remote control protocol. The timing is adapted for 4 MHz crystal **************************************************************************.include "1200def.inc".device AT90S1200.equ INPUT =2 ;PD2.equ SYS_ADDR =0 ;The system address.def S =R0 ; Storage for the Status Register.def inttemp =R1 ; Temporary variable for ISR.def ref1 =R2.def ref2 =R3 ; Reference for timing.def temp =R16 ; Temporary variable.def timerl =R17 ; Timing variable updated every 14 us.def timerh =R18 ; Timing variable updated every 16 ms.def system =R19 ; Address data received.def command =R20 ; Command received.def bitcnt =R21 ; Counter.cseg.org 0 rjmp reset ******************************************************************* "TIM0_OVF" Timer/counter overflow interrupt handler The overflow interrupt increments the "timerl" and "timerh" every 64us and 16,384us. 5

Crystal Frequency is 4 MHz Number of words:7 Number of cycles:6 + reti Low registers used:1 High registers used: 3 Pointers used:0 *******************************************************************.org OVF0addr TIM0_OVF: in S,sreg ; Store SREG inc timerl ; Updated every 64us inc inttemp brne TIM0_OVF_exit inc timerh ; if 256th int inc timer TIM0_OVF_exit: out sreg,s ; Restore SREG reti ******************************************************************* Example program Initializes timer, ports and interrupts. Calls "detect" in an endless loop and puts the result out on port B. Number of words: 16 Low registers used: 0 High registers used: 3 Pointers used: 0 ******************************************************************* reset: ;ldi temp,low(ramend);initialize stackpointer for parts with SW stack ;out SPL,temp ;ldi temp,high(ramend) ; Commented out since 1200 does not have SRAM ;out SPH,temp ldi temp,1 ;Timer/Counter 0 clocked at CK out TCCR0,temp ldi temp,1<<toie0 ;Enable Timer0 overflow interrupt out TIMSK,temp ser temp ;PORTB as output out DDRB,temp 6 AVR410

AVR410 sei ;Enable global interrupt main: rcall detect ;Call RC5 detect routine cpi system,sys_addr ;Responds only at the specified address brne release andi command,0x3f ;Remove control bit out PORTB,command rjmp main release: clr command ;Clear PORTB out PORTB,command rjmp main ******************************************************************* "detect" RC5 decode routine This subroutine decodes the RC5 bit stream applied on PORTD pin "INPUT". If success: The command and system address are returned in "command" and "system". Bit 6 of "command" holds the toggle bit. If failed: $FF in both "system" and "command" Crystal frequency is 4MHz Number of words:72 Low registers used: 3 High registers used: 6 Pointers used: 0 ******************************************************************* detect: clr inttemp ; Init Counters clr timerh detect1: clr timerl detect2: cpi timerh,8 ;If line not idle within 131ms brlo dl1 rjmp fault ;then exit dl1: cpi timerl,55 ;If line low for 3.5ms 7

brge start1 ;then wait for start bit sbis PIND,INPUT ;If line is rjmp detect1 ;low jump to detect1 rjmp detect2 ;high jump to detect2 start1: cpi timerh,8 ;If no start bit detected brge fault ;within 130ms then exit sbic PIND,INPUT ;Wait for start bit rjmp start1 clr timerl ;Measure length of start bit start2: cpi timerl,17 ;If startbit longer than 1.1ms, brge fault ;exit sbis PIND,INPUT rjmp start2 ;Positive edge of 1st start bit mov temp,timerl ;timer is 1/2 bit time clr timerl mov ref1,temp lsr ref1 mov ref2,ref1 add ref1,temp ;ref1 = 3/4 bit time lsl temp add ref2,temp ;ref2 = 5/4 bit time start3: cp timerl,ref1 ;If high period St2 > 3/4 bit time brge fault ;exit sbic PIND,INPUT ;Wait for falling edge start bit 2 rjmp start3 clr timerl ldi bitcnt,12 ;Receive 12 bits clr command clr system sample: cp timerl,ref1 ;Sample INPUT at 1/4 bit time brlo sample sbic PIND,INPUT rjmp bit_is_a_1 ;Jump if line high bit_is_a_0: clc ;Store a '0' 8 AVR410

AVR410 rol rol command system ;Synchronize timing bit_is_a_0a: cp timerl,ref2 ;If no edge within 3/4 bit time brge fault ;exit sbis PIND,INPUT ;Wait for rising edge rjmp bit_is_a_0a ;in the middle of the bit clr rjmp timerl nextbit bit_is_a_1: sec ;Store a 1 rol command rol system ;Synchronize timing bit_is_a_1a: cp timerl,ref2 ;If no edge within 3/4 bit time brge fault ;exit sbic PIND,INPUT ;Wait for falling edge rjmp bit_is_a_1a ;in the middle of the bit clr timerl nextbit: dec bitcnt ;If bitcnt > 0 brne sample ;get next bit ;All bits sucessfully received! mov temp,command ;Place system bits in "system" rol temp rol system rol temp rol system bst system,5 ;Move toggle bit bld command,6 ;to "command" andi andi ;Clear remaining bits command,0b01111111 system,0x1f ret fault: ser command ;Both "command" and "system" ser system ;0xFF indicates failure ret 9

Atmel Headquarters Corporate Headquarters 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 487-2600 Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland TEL (41) 26-426-5555 FAX (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimhatsui East Kowloon Hong Kong TEL (852) 2721-9778 FAX (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan TEL (81) 3-3523-3551 FAX (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131 TEL 1(408) 441-0311 FAX 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France TEL (33) 2-40-18-18-18 FAX (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France TEL (33) 4-42-53-60-00 FAX (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL 1(719) 576-3300 FAX 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland TEL (44) 1355-803-000 FAX (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany TEL (49) 71-31-67-0 FAX (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL 1(719) 576-3300 FAX 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France TEL (33) 4-76-58-30-00 FAX (33) 4-76-58-34-80 e-mail literature@atmel.com Web Site http://www.atmel.com Atmel Corporation 2002. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. ATMEL and AVR are the registered trademarks of Atmel. Other terms and product names may be the trademarks of others. Printed on recycled paper. 0M