6 years, 9 months ago.

Hardware Timers for quadrature encoders, problems with Timer 2 used by SysTick

Hello, I have modified, for the Nucleo F303K8, the program accessible on the page : https://developer.mbed.org/forum/platform-34-ST-Nucleo-F401RE-community/topic/4963/?page=1#comment-26870 The aim is to connect two quadrature encoders for controlling of robot. the processor of the Nucleo F303K8 possesses two timers able to handle encoders : TIM2 and TIM3 The program works fine with one encoder on Timer3 but the problem is that TIM2 is already used by mbed for SysTick. SysTick uses TIM2 for the Ticker function. I have tried to change the settings in order to free TIM2 from SysTick but I don't succeed.

I have found in the datasheet of the STM32F303K8 that it possesses a 24bit Timer especially design for SysTick, so instead of using Timer2 the mbed libraries could used the specific SysTick timer.

Does somebody knows how to proceed for resolving my problem ? Thanks for your answers Regards

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F303K8T6 microcontroller.

1 Answer

6 years, 5 months ago.

You can use timer1 and timer3 for quad encoder reading. Timer16 and timer17 for PMW generation (driving the motors).

Edit

/media/uploads/pmundt/timer1_encoder_mode.jpg

Accepted Answer

Hello Pamir, Thanks for this answer but in the datasheet of the processor it isn't mentioned that Timer 1 has the ability of handling a quadrature encoder. The following extract says tha only Timer 2 and 3 can support quadrature encoders : " 3.14.2 General-purpose timers (TIM2, TIM3, TIM15, TIM16 and TIM17) There are up to three general-purpose timers embedded in the STM32F303x6/8 (see Table 5 for differences) that can be synchronized. Each general-purpose timer can be used to generate PWM outputs, or act as a simple time base. • TIM2 and TIM3 They are full-featured general-purpose timers: – TIM2 has a 32-bit auto-reload up/down counter and 32-bit prescaler – TIM3 has a 16-bit auto-reload up/down counter and 16-bit prescaler These timers feature four independent channels for input capture/output compare, PWM or one-pulse mode output. They can work together, or with the other general- purpose timers via the Timer Link feature for synchronization or event chaining. The counters can be frozen in debug mode. All have independent DMA request generation and support quadrature encoders."

So have you already used Timer 1 with a quadrature encoder ? Thank you for the answer. Best regards

posted by Fabrice DELAMARE 08 Nov 2017

Under Advanced timer (TIM1) section (3.14.1), it says that "Many features are shared with those of the general-purpose TIM timers". Which means, TIM1 has all the features that TIM2 and TIM3 have.

Also, CubeMX allows me to select TIM1 as "Encoder Mode".

posted by Pamir Mundt 08 Nov 2017

Hello Pamir, Thanks a lot for this information. Best regards

posted by Fabrice DELAMARE 01 Dec 2017