February 2012 Doc ID 17249 Rev 2 1/34
AN3174
Application note
Implementing receivers for infrared remote control protocols
using STM32F10xxx microcontrollers
Introduction
Infrared radiation is the region of the electromagnetic spectrum which lies between
microwaves and visible light.
Infrared radiation has two ranges. Near infrared light is closest in wavelength to visible light
and far infrared is closer to the microwave region of the electromagnetic spectrum.
The shorter waves are the ones used by remote controls. Information is transmitted and
received using electromagnetic energy, without using wires.
Infrared technology offers important advantages as a form of wireless communication.
Nowadays, almost all audio and video equipment can be controlled using an infrared remote
control. At the receiving end, a receiver detects the light pulses, which are processed to
retrieve/decode the information they contain.
There are many popular infrared protocols used to transmit data via infrared light, such as
RC5, SIRC, ...
The purpose of this application note is to provide a generic solution for implementing an IR
receiver in software using a STM32F10xxx microcontroller. Example of software
implementation is provided for RC5 and SIRC protocols, other protocols are supported and
available upon request (for further information contact your local STMicroelectronics sales
office).
www.st.com
Contents AN3174
2/34 Doc ID 17249 Rev 2
Contents
1 Hardware considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Generic solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 RC5 protocol solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1 Protocol basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Software implementation using a single GPIO
with a generic timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1 RC5 frame reading mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Software implementation using a GP-Timer configured
in PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3.1 RC5 Frame decoding mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3.2 RC5 library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3.3 How to use the RC5 decoder driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Comparison of RC5 solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4 SIRC infrared control solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1 Protocol basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Software implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3 SIRC library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.4 How to use the SIRC decoder driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5 Interface layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 How to use the IR driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.1 Demonstration programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.1.1 Demo using GP-Timer configured in PWM mode . . . . . . . . . . . . . . . . . 26
6.1.2 RC5 demo using a single GPIO with generic timer . . . . . . . . . . . . . . . . 26
7 How to customize the IR drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
9 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32