www.ti.com
IR Signal Generation and Learning
9.9 IR Signal Generation and Learning
This section describes how Timer 1 can be configured in IR generation mode, where it counts Timer 3
periods and the output is ANDed with the output of Timer 3 to generate modulated consumer IR signals
with minimal CPU interaction.
9.9.1 Introduction
Generation of IR signals for remote control is generally done in one of two ways:
• Modulated codes
• Non-modulated codes (C-codes, flash codes)
The device includes flexible timer functionality to implement generation and learning of both types of IR
signals with minimal CPU interaction. Most IR protocols can be implemented with only one CPU
intervention per command.
9.9.2 Modulated Codes
Modulated codes can be generated using Timer 1 (16-bit) and Timer 3 (8-bit). Timer 3 in modulo mode is
used to generate the carrier. Timer 3 has an individual prescaler for its input. Its period is set using
T3CC0. Timer 3 channel 1 is used for PWM output. The duty cycle of the carrier is set using T3CC1.
Channel 1 uses compare mode: Clear output on compare, set on 0x00 (T3CCTL1.CMP = 100). Table 9-2
shows the frequency error calculation for a 38-kHz carrier using Timer 3.
Table 9-2. Frequency Error Calculation for 38-kHz
Carrier
Description Value
System clock frequency 32,000 kHz
IR carrier frequency 38 kHz
System clock period 0.00003125 ms
IR carrier period 0.026315789 ms
Timer prescaler 4
Timer period 0.000125 ms
Ideal timer value 210.5263158
True timer value 211
True timer period 0.026375 ms
True timer frequency 37.91469194 kHz
Period error 59.21052632 ns
Frequency error 85.30805687 Hz
Frequency error % 0.2245%
The IRCTL.IRGEN register bit enables IR generation mode in Timer 1. When the IRGEN bit is set, Timer
1 takes the output of the Timer 3 channel 1 compare signal as tick instead of the system tick. The Timer 1
period is set using T1CC0 with Timer 1 in modulo mode (T1CTL.MODE = 10) and channel 0 in compare
mode (T1CCTL0.MODE = 1). Channel 1 compare mode Clear output on compare, set on 0x0000
(T1CCTL1.CMP = 100) is used for output of the gating signal.
The number of mark carrier periods is set by T1CC1. T1CC1 must be updated every Timer 1 period by the
DMA or CPU. Note that an update to T1CC1 is buffered and does not take effect before Timer 1 reaches
0x0000.
The number of space carrier periods is set by T1CC0. Its value should be set to the total number of mark
and space carrier periods wanted. The compare values are buffered until the timer hits 0x0000.
The output of Timer 1 channel 1 is ANDed with that of Timer 3 channel 1 to form the IR output as shown
in Figure 9-7
115
SWRU191C–April 2009–Revised January 2012 Timer 1 (16-Bit Timer)
Submit Documentation Feedback
Copyright © 2009–2012, Texas Instruments Incorporated