cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 Demodulated Infrared Receiver Input

Atilla Mete Turedi
Associate II
Posted on September 27, 2017 at 14:16

Greetings community,

I am developing an IR learning hardware that can transmit its learned IR codes as well. For the transmitter part, I will be using the IR_OUT pin (PA13).

For the receiver part, from AN4834, I understand that a General Purpose Timer needs to be configured in PWM input to capture incoming demodulated IR data. The STM32L4 has 3 x GP Timers, namely TIM15, TIM16 and TIM2, As TIM 15 and TIM 16 are used for the modulation of the transmitted Infrared signal, that leaves me only with TIM2 to be used for my specific purpose.

That brings it to my question; which pin should I connect the demodulated infrared signal at STM32L4 so I can use TIM2 as PWM input to capture the data stream.

Best Regards,

Mete

#general-purpose-timers #tim2 #tim #ir #pwm #ir_out #tim16 #stm32l4 #infrared
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on September 28, 2017 at 00:05

Hello Mete!

which pin should I connect the demodulated infrared signal at STM32L4 so I can use TIM2 as PWM input to capture the data stream.

You may use TIM2_CH1 or TIM2_CH2 as PWM inputs.

Inside of your device's DataSheet, you will find the exact pins which are connected internaly to theese TIM2 channels.

The next example is from RM0394

In same RM,   TI1 is the TIM2_CH1 pin and TI2 is TIM2_CH2 pin.

0690X00000608INQAY.png

 this example uses  TI1 as the PWM input .

0690X00000608PSQAY.png0690X00000608IDQAY.png

There are also working examples how to use PWM input at L4

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubel4.html

Regards

vf

View solution in original post

6 REPLIES 6
Posted on September 28, 2017 at 00:05

Hello Mete!

which pin should I connect the demodulated infrared signal at STM32L4 so I can use TIM2 as PWM input to capture the data stream.

You may use TIM2_CH1 or TIM2_CH2 as PWM inputs.

Inside of your device's DataSheet, you will find the exact pins which are connected internaly to theese TIM2 channels.

The next example is from RM0394

In same RM,   TI1 is the TIM2_CH1 pin and TI2 is TIM2_CH2 pin.

0690X00000608INQAY.png

 this example uses  TI1 as the PWM input .

0690X00000608PSQAY.png0690X00000608IDQAY.png

There are also working examples how to use PWM input at L4

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubel4.html

Regards

vf

Posted on September 28, 2017 at 07:36

Dear Vangelis,

Thank you very much for your detailed response. I understand that the adjacent signal to the selected channel is also used for the PWM input because both edges need to be detected.

Does this mean that the pin the adjacent channel is connected cannot be used for other purposes?

Best Regards,

Mete

Posted on September 28, 2017 at 15:20

Hello again.

Does this mean that the pin the adjacent channel is connected cannot be used for other purposes?

It can used for other purposes yes. except TIM2_CHx because this functionality is connected internal to the other pin

x is the non used input.(1, or 2).

E.g. it can used as normal GPIO pin.

Regards

Vf

Posted on October 04, 2017 at 15:02

Dear

FORTOUNAS.EVANGELOS

‌,

I am sorry for the necromancy but one more question if you may;

0690X00000608TLQAY.png

Am I missing anything with this config? I chose to use TIM2_CH2 for direct input capture mode. I am not sure if the Slave Mode, Trigger Source and Clock Source are set correctly or not. Is there a configuration example for PWMI anywhere I can base my design around?

I thought the signal path for PWMI would be as such when CH2 is selected. Do you think it is correct?

0690X000006042IQAQ.jpg

Best Regards,

Mete

Posted on October 04, 2017 at 15:41

Hello Mete.

The scheme is like this

0690X00000608TeQAI.png0690X00000608TZQAY.png

to use the PWM Input mode from CUBEMx  must selected from the combined channels droplist.

To start the PWM Input , in your main function, call HAL_TIM_IC_Start (or HAL_TIM_PWM_Start)      (for both channels).

And don't forget to put inside TIM2 settings, the counter period(AR Register) to a higher value than PWM period you try to measure.

regards

vf

Posted on October 04, 2017 at 15:50

Dear Evanghelos,

to use the PWM Input mode from CUBEMx  must select the combined channels droplist.

Thank you very much my dear friend. This helps a lot and I shouldn't have missed that.

Best Regards,

Mete