Microchip | The Embedded Control Solutions Company Register Login
Browse All
 6 Code Snippets

Infrared Remote Controls (Philips RC-5 Protocol)


RC-5 Protocol Philips – Remote Control protocol. A variety of inexpensive remote controls with the encoding RC-5, produced by various manufacturers, making it attractive for controlling home appliances.

About this Code Example

Attention Translation Google. If you are experiencing a lack of understanding, please refer to the original.
Purpose of the library.
Decode the signal and receiving commands (key code) in the format of one byte. For use with PIC microcontrollers from Microchip.
Tested with a C compiler:
HI-TECH C Compiler for PIC18 MCUs (PRO Mode)  V9.80
HI-TECH C Compiler for PIC10/12/16 MCUs (PRO Mode)  V9.83
Version MPLAB v8.80

Connecting the library.
To connect the library to do the following:
1.  Сonfigure the input INT
      INTEDG=0;                                 // Interrupt on falling edge of RB0/INT pin
2. Enable interrupts
     TMR1IE=1;                                   // enable interrupts from TMR1
     INTCON=0b11010000;               // Enables the RB0/INT external interrupt
The threshold duration control 889 + (889 / 2) = 1331 ms.
Use a timer TMR1, prescaler set to 1:1, to control the duration, we use the value of the register TMR1H.
3. Set the clock frequency in Hertz
#define _XTAL_FREQ 20000000 // Our clock 20 Mh
4. Determine the input connection of a sensor.
#define IKDU RB0       // port that is connected to a photodetector.
5. In the interrupt function must be placed IR_RC5 ();
void interrupt my_isr(void) //
      IR_RC5 ();     // Decode RC5 code.   
6. The value of the team get into a variable command.
Library functions.
IR_RC5 ();          / / Decode RC5 code must be placed in the function of the interrupt.
Some features. RC-5 protocol has no mechanism for protection against interference with the IR range, but you can improve immunity, using some features of the protocol. From experience, bits 4, 5, 6 is always equal to zero, this feature can be used to control noise. In the presence of these bits to "1", the program considers the current adopted code, incorrect. If these bits to "0" adopted code be considered successful.
 Another option decoder (this is not implemented) should be to include the detection signal of the front, was allowed only in the expected period of time where there should be change the front signal. In the rest of the time interrupt edge is prohibited.



Release History

  • Nov 10, 2011

    Version: 1.0.0

    Tested on many devices, very little code.

  • Nov 9, 2011

    Version: 1.0.0

    Tested on many designs, a very small code size.

  • Nov 9, 2011

    Version: 1.0.0

    Tested on many designs, very little code.

Download Contact the Developer

*Required Fields

  • Current Version:1.0.0
  • Created:Nov 10, 2011
  • Updated:Feb 26, 2015
  • Downloads:9369
  • MPLAB Version:8.80
  • C Compiler:HI-TECH C Compiler
  • Development Tools:ICD2
  • Supported Devices:PIC16/PIC18

Corporate News


Stay Connected

Stay up to date with the latest news from Microchip Technology.