cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429ZIT6 Encoder Mode not counting

DPatr.2
Associate III

I have a custom PCB with a STM32F429ZIT6 on, I am using CubeMX and STM32CubeIDE.

The board generates encoders signals with TIM1 & TIM3 in Output Compare mode.

I can scope and see the correct encoder signals being generated by both timers.

Then, I also want to read those signals.

To do so, I am using TIM2 and TIM5 as Encoder Mode.

TIM5 has no issue return encoder count with htim5->Instance->CNT

However, TIM2 doesn't return anything.

Looking into SR (Status Register) of TIM2


_legacyfs_online_stmicro_images_0693W00000blEsJQAU.pngI can see CC1IF & CC1OF bits to be reset for TIM2.

CCR1 & CCR2 of TIM2 are also empty when making the read instruction to CNT.

Reading into CC1IF Descriptions:

"If channel CC1 is configured as input:

[...]

0: No input capture occured

1: The counter value has been captured in TIMx_CCR1 register (An edge has been detected on IC1 which matches the selected polarity)"

As far as I know, putting the Timer in Encoder Mode is configuring CC1 and CC2 as input.

And, I can scope encoder signals coming into PA5 (TIM2_CH1) & PB3 (TIM2_CH2).


_legacyfs_online_stmicro_images_0693W00000blF1GQAU.png
_legacyfs_online_stmicro_images_0693W00000blF1LQAU.png 

Any Idea where to look?

Thank you for the support.

5 REPLIES 5

CH1 is not working.

Read out and check/post relevant GPIO registers content.

Measure directly on mcu's pins (think of bad solder joints). Alternatively, set the given pin(s) as GPIO outputs, toggle them and observe.

JW

PS. Decimal printout of registers is not that useful.

Thank you for the comments;

I have checked for bad solder joint by setting PA5 & PB3 as GPIO output instead of TIM2_CH1 & TIM2_CH2. (Great Idea by the way).

I toggle both PA5 & PB3 and can see the associated signal on scope.

It's an issue with my firmware.

There's a bunch of other peripherals setup (Other timers, PWM generation with DMA, many many EXTI (8), USB) and my hypothesis is there is conflict between one of them and TIM2.

For binary/hex content of SR registers;

TIM5->SR = 0b11000011111 = 0x619

TIM2->SR = 0b10000011101 = 0x41d

DPatr.2
Associate III

TIM5->SR = 0b11000011111 = 0x619

TIM2->SR = 0b10000011101 = 0x41d

TIMx SR are ok.

Read out and check/post relevant GPIO registers content.

JW

DPatr.2
Associate III

It was a hardware issue, we resoldered another STM32F429 onto the custom PCB and everything works!