1
\$\begingroup\$

I would like to know if it is possible to remap a single pin of a multi-pin (SPI) peripheral?

For instance, I have a STM32F107 and I want to use UART4, SPI3 and Ethernet.

PC10 = UART4_TX - Remap function = SPI3_SCK

PC11 = UART4_RX - Remap function = SPI3_MISO

PC12 = UART5_TX - Remap function = SPI3_MOSI

PB3 = SPI3_SCK

PB4 = SPI3_MISO

PB5 = Ethernet or SPI3_MOSI - I have to use ethernet.

What I want to do is to use PC12, PB3 and PB4 for SPI3, and then use PC10 and PC11 for UART4.

Is it allowable to only remap one pin and not the entire peripheral?

I would like to use the HAL libraries to configure, if possible.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I'm not familiar enough with the F1 series to answer your question definitively, but I can verify that this is possible (even through the HAL libraries) on an STM32F3 and STM32F4. You may find the STM32CubeMX tool helpful in pinning out STM32Fx parts: st.com/content/ccc/resource/technical/document/data_brief/7a/81/… \$\endgroup\$
    – max
    May 19, 2016 at 8:01
  • \$\begingroup\$ Some micros are more configurable than others, unfortunately to find out for sure you'd pretty much have to go through the SPi section of the full manual with a fine toothed comb to see if it has that kind of functionality. \$\endgroup\$
    – Sam
    May 19, 2016 at 8:06

1 Answer 1

2
\$\begingroup\$

In general: check the reference manual. Some peripherals can be partially remapped in various different ways; others cannot.

In this specific case: no. Remapping of the SPI3 peripheral is controlled by a single bit in the AFIO mapping register (SPI3_REMAP in AFIO_MAPR); there's no way to do it partially. If possible, you may want to consider using different SPI and/or UART peripherals, or using an I/O expander to reduce the number of peripherals you need. Another option may be to remap the Ethernet peripheral.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for correcting me, I did not know this fact so far. \$\endgroup\$ May 19, 2016 at 8:07
  • \$\begingroup\$ Thank you, I did not know about the reference manual, next time I will know to check it first! The following extract is from the reference manual: Bit 28 SPI3_REMAP: SPI3 remapping This bit is set and cleared by software. It controls the mapping of SPI3 NSS, SCK, MISO, MOSI alternate functions on the GPIO ports. 0: No remap (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5) 1: Remap (NSS/PA4, SCK/PC10, MISO/PC11, MOSI/PC12) Note: This bit is available only in connectivity line devices and is reserved otherwise. \$\endgroup\$
    – AJBotha
    May 19, 2016 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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