cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE+STM32G4: encoder mode select internal signal input from comparators

Andrea Canepa
Senior

With STM32G4 the use of counters to decode signals from quadrature encoders has been significantly improved. Furthermore we can use the comparators to detect the counting front and save external pins avoiding to make the signal come out from the comparator to let it enter the timer input connected to TI1 (for example).

Unfortunately in the settings of STM32CubeIDE (and STM32CubeMX) when the "Encoder Mode" is selected in the timer, there is no possibility to change the source of the signals sent to "tim_ti1fp1" and "tim_ti2fp2", and two hardware pins are automatically enabled in the GPIO:

0690X000009YymTQAS.jpg

In reality, using the "TIMx_TISEL" register, it is possible to select the source for the TIx signal and send the counting signal internally from the comparator (for example). All this is a beautiful thing because it avoids the external passage of the signal and the useless waste of pins.

The question is: why in the "IC Selection" line is set to "Direct"and it is not possible to select also the other remapped sources? This way you can avoid having to manually access the registers to modify TIMx_TISEL register.

Or the settings of the sources for "Channel 1" and "Channel 2" should remain active with the possibility of being modified, instead now they become gray and blocked.

1 ACCEPTED SOLUTION

Accepted Solutions
Andrea Canepa
Senior

I received a response from "STM technical assistance":

"This is bug in STM32CubeIDE /CubeMX. A developers forgot add selection of TI inputs. I reported it them. For this moment you have to do manually. You have to discard setting for pins CH1/2 and add this function HAL_TIMEx_TISelection to initialization for TIM."

View solution in original post

1 REPLY 1
Andrea Canepa
Senior

I received a response from "STM technical assistance":

"This is bug in STM32CubeIDE /CubeMX. A developers forgot add selection of TI inputs. I reported it them. For this moment you have to do manually. You have to discard setting for pins CH1/2 and add this function HAL_TIMEx_TISelection to initialization for TIM."