27. Infrared interface (IRTIM)

An infrared interface (IRTIM) for remote control is available on the device. It can be used with an infrared LED to perform remote control functions.

It uses internal connections with USART1, USART4 (on STM32G071xx/G081xx/G0B1xx/G0C1xx) or USART2 (on STM32G031xx/G041xx/G051xx/G061xx), TIM16, and TIM17 as shown in Figure 278 .

To generate the infrared remote control signals, the IR interface must be enabled and TIM16 channel 1 (TIM16_OC1) and TIM17 channel 1 (TIM17_OC1) must be properly configured to generate correct waveforms.

The infrared receiver can be implemented easily through a basic input capture mode.

Figure 278. IRTIM internal hardware connections

Figure 278: IRTIM internal hardware connections diagram. The diagram shows the internal logic of the IRTIM block. On the left, four input sources are shown: TIM17_CH1 (producing a high-frequency carrier signal), TIM16_CH1 (producing a modulation envelope), USART1, and USART4^(1) (also producing a modulation envelope). The TIM17_CH1 signal is connected to one input of an AND gate. The outputs of TIM16_CH1, USART1, and USART4 are connected to a multiplexer. The output of the multiplexer is connected to the other input of the AND gate. The output of the AND gate is connected to an OR gate. The OR gate also receives input from the IR_POL register. The output of the OR gate is the IR_OUT signal, which is shown as a modulated infrared signal. The IRTIM block also includes configuration registers IR_MOD[1:0] and IR_POL. The diagram is labeled MS44790V2 in the bottom right corner.
Figure 278: IRTIM internal hardware connections diagram. The diagram shows the internal logic of the IRTIM block. On the left, four input sources are shown: TIM17_CH1 (producing a high-frequency carrier signal), TIM16_CH1 (producing a modulation envelope), USART1, and USART4^(1) (also producing a modulation envelope). The TIM17_CH1 signal is connected to one input of an AND gate. The outputs of TIM16_CH1, USART1, and USART4 are connected to a multiplexer. The output of the multiplexer is connected to the other input of the AND gate. The output of the AND gate is connected to an OR gate. The OR gate also receives input from the IR_POL register. The output of the OR gate is the IR_OUT signal, which is shown as a modulated infrared signal. The IRTIM block also includes configuration registers IR_MOD[1:0] and IR_POL. The diagram is labeled MS44790V2 in the bottom right corner.

3. USART4 on STM32G071xx/G081xx/G0B1xx/G0C1xx, and USART2 on STM32G031xx/G041xx/G051xx/G061xx.

All standard IR pulse modulation modes can be obtained by programming the two timer output compare channels.

TIM17 is used to generate the high frequency carrier signal, while TIM16 or alternatively USART1 or USART4 generates the modulation envelope according to the setting of the IR_MOD[1:0] bits in the SYSCFG_CFGR1 register.

The polarity of the output signal from IRTIM is controlled by the IR_POL bit in the SYSCFG_CFGR1 register and can be inverted by setting of this bit.

The infrared function is output on the IR_OUT pin. The activation of this function is done through the GPIOx_AFRx register by enabling the related alternate function bit.

The high sink LED driver capability (only available on the PB9 pin) can be activated through the I2C_PB9_FMP bit in the SYSCFG_CFGR1 register and used to sink the high current needed to directly control an infrared LED.