2022-08-05 11:23 AM
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:
Further, 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:
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?
Solved! Go to Solution.
2022-08-06 01:46 AM
> 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
2022-08-05 01:45 PM
> The question is: where in the RM0090 is said to set the AF to enable encoder functionality?
The '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
2022-08-05 02:38 PM
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.
Best regards!
2022-08-06 01:46 AM
> 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
2022-08-06 01:57 AM
2022-08-07 01:33 AM