cancel
Showing results for 
Search instead for 
Did you mean: 

Using peripherals when they share (some of) the same pins

nicholas2399
Associate II
Posted on July 25, 2012 at 10:47

I am using the STM32F103C8T6. I notice that some of the peripherals share the same pins. What I am wondering is whether it is possible to use these peripherals in these circumstances.

The specific case I am looking at are UART3 and SPI2, neither of which can be re-mapped (not on the version of the device I am using)

Now UART3 is on pins PB10, PB11, PB12, PB13 and PB14 (I am only interested in TX and RX on PB10 and PB11), whereas SPI2 is on pins PB12, PB13, PB14, PB15 ( I am only interested in SCK, MISO and MOSI on PB13, PB14, PB15)  Is it possible to use both peripherals in this way?

If so what mechanism stops the UART CTS and RTS functions affecting the SPI2 SCK and MISO functions?

Thanks in advance

Nick

#peripherals-stm32f103c8t6
11 REPLIES 11
frankmeyer9
Associate II
Posted on July 25, 2012 at 11:16

You can certainly change the pin assignment at runtime when assigning the pins to another alternate function, and de-initializing the other peripheral before.

However, you still need to keep external circuitry from interfering with it. Shutting down the UART will not keep an external device from sending, thus affecting the former RX pin for instance.

nicholas2399
Associate II
Posted on July 25, 2012 at 13:04

Thanks for the response.

I actually would like to use both peripherals at the same time. This is what I want to check if it is possible or not.

frankmeyer9
Associate II
Posted on July 25, 2012 at 13:25

I have not been looking at the datasheet you actually want to use, but this is basically always the same. The selection of the 'Alternate Function' of the pin(s) is an either-or choice.

A usage at the same time is not possible, at least for the same pin.

Several peripherals are routed to different pins or pin sets, especially UART and I2C/SPI.

I would double check if not one slipped through.

leventeyigel52
Associate II
Posted on July 25, 2012 at 21:58

Look at the datasheet of microcontroller,

and use the GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState)

I hope SPI or USART have another pins, if you use Remap Function you can use these peripherals

Andrew Neil
Evangelist III
Posted on July 25, 2012 at 22:33

''what mechanism stops the UART CTS and RTS functions affecting the SPI2 SCK and MISO functions?''

If you don't configure the pins for the CTS and RTS alternate functions, then they are available for other uses...

frankmeyer9
Associate II
Posted on July 26, 2012 at 07:21

That is correct.

I understood the first post that he intents :

1. use both peripherals at the same time

2. use the UART with hardware handshake, i.e. RX/TX and CTS/RTS

That is not possible with just one set of pins.

John F.
Senior
Posted on July 26, 2012 at 09:16

ST's tool, ''MicroXplorer - MCU graphical configuration tool'' is useful as it quickly shows where alternative functions are mapped to pins. Unfortunately, it seems to assign functions as complete blocks although as Neil says, you don't have to configure all the pins of a USART if for example you only want TX /RX.

Quickest way to find the tool is just Google ''STM32 MicroXplorer''.

Andrew Neil
Evangelist III
Posted on July 26, 2012 at 20:06

''I understood the first post that he intents ... use the UART with hardware handshake, i.e. RX/TX and CTS/RTS''

No: he specifically said that he is interested in Rx and Tx only - ie, not CTS & RTS.

mk299
Associate III
Posted on July 26, 2012 at 20:39

Maybe you could be more specific which peripherals exactly you'd like to use.