I am working on the assignments of pins of STM32F103ZET1.

On page 31 of datasheet, it says that PA0 has many alternative functions: TIM2_CH1_ETR \ USART2_CTS \ WKUP \ ADC123_IN0 \ TIM5_CH1 \ TIM8_ETR. From the reference manual, I know that TIM2_CH1_ETR and USART2_CTS can be remapped.

What about other functions? What if I want to use TIM5_CH1 and TIM8_ETR at the same time? How can the STM32 know whether I want to consider PA0 as TIM5_CH1 or TIM8_ETR?

1: datasheet, reference manual


After spending a few minutes searching the datasheet, I've concluded that you can't remap those functions. However, they're both inputs. So you can use them both at once to trigger different things in those two timers.

  • \$\begingroup\$ thanks a lot, i know that reference manual does not say anything about how to map TIM5_CH1 or TIM8_ETR to PA0. then, problem arises, different functions share the same pin(PA0) and no specific registers to distinguish them. if i have enabled these two functions, and then PA0 gets a signal, will stm32 send it to TIM5 or TIM8 \$\endgroup\$ – oilpig May 2 '13 at 14:55
  • \$\begingroup\$ I would say both when the manual doesn't say otherwise. \$\endgroup\$ – Turbo J May 2 '13 at 15:19
  • \$\begingroup\$ Yes, I'd assume that both functions are wired to that input and the signal will go to both of them. \$\endgroup\$ – pjc50 May 2 '13 at 15:29
  • \$\begingroup\$ Some microcontrollers only require one to select the functions associated with output pins; for input functions that can be mapped to more than one pin, a separate configuration area may be used to select the input associated with a pin. Such designs allow one input to serve multiple functions. The STM32 doesn't work like that, however. For a module to see an input from a pin, that pin has to be configured as being connected to that module, and thus cannot be connected to any other module. \$\endgroup\$ – supercat May 2 '13 at 19:05
  • \$\begingroup\$ .....hey,supercat,since stm32 does not have that function(one input to serve multiple functions), it has no reason to have one pin(PA0) with two functions(TIM5 TIM8) without configurations about remapping or something else.... \$\endgroup\$ – oilpig May 3 '13 at 4:53

Microcontrollers typically are designed around compromises on pin-count versus desired functions.

Thus, there will typically be a set of configuration ports or configuration registers, which define for the microcontroller how a given pin should behave. At a simplistic level, picture the parallel with a GPIO being used as input or as output, depending on configuration.

If such polymorphic functionality of pins were not implemented, an MCU would need many many more pins than they usually have, quickly getting into the realms of the impractical.

If an application needs a pin to be used for different functions at different points in code, typically there is set-up code written as part of the application, before each usage block, setting the configuration registers accordingly. Consider the GPIO-as-input/output example above.

  • \$\begingroup\$ thanks a lot, it seems that i can not use these two functions at the same time but i can enable one of them at a particular time and then, i can enbale another function after disabling the one stm32 is using \$\endgroup\$ – oilpig May 2 '13 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.