cancel
Showing results for 
Search instead for 
Did you mean: 

When I use both chanels, what args I need in HAL_TIM_Encoder_Start?

dungeonlords789
Senior III

I use CubeMX to configure my timer 2 to use Encoder Mode: "Encoder Mode TI1 and TI2". In my code should I use

HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_1)

or

HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_2)

or

HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL)

or something else?

P.S. What means TI1?

1 ACCEPTED SOLUTION

Accepted Solutions
Amel NASRI
ST Employee

Hi @dungeonlords789​ ,

Looking to the description of HAL_TIM_Encoder_Start in the driver stm32f4xx_hal_tim.c (for example):

/**

 * @brief Starts the TIM Encoder Interface.

 * @param htim TIM Encoder Interface handle

 * @param Channel TIM Channels to be enabled

 *     This parameter can be one of the following values:

 *      @arg TIM_CHANNEL_1: TIM Channel 1 selected

 *      @arg TIM_CHANNEL_2: TIM Channel 2 selected

 *      @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected

 * @retval HAL status

 */

So the last option is what you need to use.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Amel NASRI
ST Employee

Hi @dungeonlords789​ ,

Looking to the description of HAL_TIM_Encoder_Start in the driver stm32f4xx_hal_tim.c (for example):

/**

 * @brief Starts the TIM Encoder Interface.

 * @param htim TIM Encoder Interface handle

 * @param Channel TIM Channels to be enabled

 *     This parameter can be one of the following values:

 *      @arg TIM_CHANNEL_1: TIM Channel 1 selected

 *      @arg TIM_CHANNEL_2: TIM Channel 2 selected

 *      @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected

 * @retval HAL status

 */

So the last option is what you need to use.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.