cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Encoder functionality on STM32F407VE vs STM32F103C8

Echo
Associate II

Setting the encoder functionality on STM32F103C8 is straight forward, just set the registers that's due. But on STM32F407VE it seems more tricky: using PA6 and PA7 on TIM3, if you follow what is said in the RM0090, page 616, you're not ready to go:

0693W00000QN5uxQAD.pngFurther, I've discovered I had to configure the AF function to the pins 6 and 7 and then attach AF to TIM3 setting AF2 to register GPIOx_AFRL on pins 6 and 7:

0693W00000QN5wAQAT.png The question is: where in the RM0090 is said to set the AF to enable encoder functionality?

(On STM32F103C8 it's not necessary to attach TIM3 to AF, you simply have to follow the recipe, unlike for the STM32F407VE).

Would this section of RM0090 be a simply copy-and-paste from RM0008, where it works flawlessly?

1 ACCEPTED SOLUTION

Accepted Solutions

> do all functions within "Alternate Functions box" (really) demand AF registers to be set? I think that is a bit confusing from RM's reader point of view.

In 'F4 and all other STM32, yes. If you don't set for given pin MODER bits to 0b10 = AF, that pin for any peripheral simply does not exist (is entirely disconnected, both for input and output). And after you set for that pin MODER to 0b10, it exists only for the peripheral you've selected for that pin in the AFR/AFL register.

I don't use the 'F1 but if I am not mistaken, you *can* set . In other words (although that may confuse you even more), in 'F1 the input is connected directly from pin to the peripheral's internal input, while output from peripheral's internal output goes to the pin through a switch controlled by the GPIO_CRL/CRH.CNF1 bit.

JW

View solution in original post

5 REPLIES 5

> The question is: where in the RM0090 is said to set the AF to enable encoder functionality?

0693W00000QN6E4QAL.pngThe 'F1 is the exception, an early rather imerfect model with more-less fixed pin-to-peripheral relationship; all other STM32 do have the GPIO matrix same as in 'F4, providing somewhat more (albeit not perfect) flexibility.

JW

waclawek.jan, First of all, thanks for your precise answer!

From both datasheets (F103 and F407) there are AF. In F103, some functions are implemented setting AF registers (like PWM output functions) and some are not (like encoder functions), even being called "Alternate Function" by the RM0008.

Does it occurs to the F40xxx, or to be specific, do all functions within "Alternate Functions box" (really) demand AF registers to be set? I think that is a bit confusing from RM's reader point of view.

0693W00000QN6IGQA1.png0693W00000QN6IaQAL.pngBest regards!

> do all functions within "Alternate Functions box" (really) demand AF registers to be set? I think that is a bit confusing from RM's reader point of view.

In 'F4 and all other STM32, yes. If you don't set for given pin MODER bits to 0b10 = AF, that pin for any peripheral simply does not exist (is entirely disconnected, both for input and output). And after you set for that pin MODER to 0b10, it exists only for the peripheral you've selected for that pin in the AFR/AFL register.

I don't use the 'F1 but if I am not mistaken, you *can* set . In other words (although that may confuse you even more), in 'F1 the input is connected directly from pin to the peripheral's internal input, while output from peripheral's internal output goes to the pin through a switch controlled by the GPIO_CRL/CRH.CNF1 bit.

JW

0693W00000QN7JFQA1.png0693W00000QN7MsQAL.png

Echo
Associate II

Thanks so much for the explanation!

You made life easier!

Best regards, waclawek.jan