8 years, 10 months ago.

porting to STM32F1xx

Thanks for sharing. This is a great help to me and I am sure many others. It is really the best code I've found for doing the encoders using timers of the STM32... and I've look A LOT !

I successfully ported the code to run on my STM32F103 but am left with a question. I was unable to set a value for GPIO_InitStruct.Alternate in my HAL_TIM_Encoder_MspInit() function as the GPIO_InitTypeDef struct defined in stm32f1xx_hal_gpio.h lacks that member (Alternate). So I just have that line commented out and as I said, it does runs! I'm using GPIO_PIN_6 and GPIO_PIN_7 of GPIOA which is utilizing TIM3.

Any idea why defining Alternate is not necessary? I'd rather not leave that unknown dangling out there and then have things quit on me down the road when I twiddle something.

Again, thanks a million. Paul

Question relating to:

Hello World example for interfacing up to four rotary encoders to the STM32's timer/counter hardware, without interrupts.

Hello Paul and apologies for not seeing this earlier. I've just had a quick read of the F103 datasheet and as you have noticed it handles GPIO alternate functions differently to the MCU families I looked at. By copying eg my F4 code & using the same for the F1 with the incompatible alternate mode setting line commented out, you are relying on the GPIO pin's default state after reset. TIM1 @ PA8 PA9, TIM2 @ PA0 PA1 and TIM4 @ PB6 PB7 would appear to be usable too as default pin usage after reset (unless mbed itself has set them as alternate or employed for systick).

posted by David Lowe 20 Sep 2015
Be the first to answer this question.